News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

masm with spinx c--

Started by Emil_halim, October 15, 2013, 11:35:23 PM

Previous topic - Next topic

Emil_halim

Hi Vortex,

I have no experience of anti virus  Seriously , so i  downloaded  avira anti virus and starting scan my system.

deleted done.

does avira repare  that problems. 

TWell

I use Avast free scanner, no actual virus in that zip ?
That might be heuristic problem again ?
So, what file inside zip is infected ?
Colfire.exe ??

VirusTotal Detection ratio: 4 / 48

CAT-QuickHeal    (Suspicious) - DNAScan    20131018
Comodo    MalCrypt.Indus!    20131018
TrendMicro    PAK_Generic.001    20131018
TrendMicro-HouseCall    PAK_Generic.001    20131018

@Emil_halim
You could split that package to smaller parts.
Let people download OllyDbg if they wish.



Vortex

Hi Emil,

Me too, I am an Avira user but no any AV can provide 100% guarantee. Scan all the drives of your computer and be sure that you have a safe programming environment.

avcaballero

I've got that av warning in some c-- progs examples, though I assumed a false positive. It is very usual in no common tools? in tinyc many times too. One way to avoid such false positive is providing just the code and the compiler... Or just the source codes in "unsafe" exes...

Regards

Emil_halim

Hi TWell,

after installing anti virus it has detected some virus , just like you post , the file  Colfire.exe  is infected .

but there is 2 exe of that file one is downloaded from net , the site i was posted later of sphinx c-- , and the
other is compiled in my system and has no virus.

any way i will check all exe in the zip file and repost again.

@Vortex

ok , i am doing.

@ avcaballero

thank you , all programs in example was downloaded from the site of c-- , i will check them all.   
   

Emil_halim


Hi all,

Okay  here is a clean zip file.

download here http://speedy.sh/aDd4G/Ext-c.rar

Enjoy codeing c-- & masm.

Vortex

Hi Emil,

Not to be pedantic and no offence but you don't need a site like that to share your code :

QuoteDownload this file for free using Tiny DM manager (exe app)

It asks to use a download manager.

Kindly, could you delete all the executables in your archive? You can attach here the resulting zip archive.

Emil_halim

Quote from: Vortex on October 18, 2013, 10:18:14 PM
Hi Emil,

Not to be pedantic and no offence but you don't need a site like that to share your code :


all your advises are be welcome any time.

here is an other like http://bcxdx.spoilerspace.com/C--/Ext_c--.rar

Emil_halim

Hi all,

Here is an other example that accept a term "uses" with masm procedure.

this masm code is Mr dedndave's code ,  topic : http://masm32.com/board/index.php?topic=1046.0


/*************************************
*           Sphinx C--               * 
*                                    *
*    Uses in proc test from masm     *
*                                    *
*         by Emil_halim              *         
*                                    *
*************************************/


#pragma option w32c       //create Windows console EXE.
#pragma option OS         //speed optimization
#jumptomain NONE          //just jump to main function

#includepath "D:\Ext_c--\winlib" 

#include <windows.h> 
#include <MSVCRT.H-->
 
#pragma option ia        //allow inserte asm instructions


#pragma option LST

^^
; #########################################################################
;  topic :
;  http://masm32.com/board/index.php?topic=1046.0
;
;  it is Mr dedndave's code
; #########################################################################
FillArray PROC MyArray:DWORD USES EBX ESI EDI

        mov     edi, MyArray   
        xor     eax,eax
        mov     ebx,1
        mov     edx,2
        mov     esi,3
        mov     ecx,1000/4

FArry0: mov     [edi],eax
        mov     [edi+4],ebx
        mov     [edi+8],edx
        mov     [edi+12],esi
        add     eax,4
        add     ebx,4
        add     edx,4
        add     esi,4
        add     edi,16
        sub     ecx,1
        jnz     FArry0

FillArray ENDP
; #########################################################################
^^

void main()
{
     int Arry[1000];
               
     FillArray(#Arry);
     
     printf("%d\n",Arry[ 489 * sizeof int ]);  // c-- can not calculate array adress
           
     MessageBox(0,"","",0);
}



habran

It looks interesting :biggrin:
What about source level debugging?
64 bit?
Cod-Father

Emil_halim

Quote from: habran on October 19, 2013, 08:16:43 PM
It looks interesting :biggrin:

thanks , the interesting thing is that you can use high level asm with Masm code .

ie. instead of writing this

   mov al , byte ptr [esi]


you can do it like that

  al = char [ esi]


Quote from: habran on October 19, 2013, 08:16:43 PM
What about source level debugging?

I am afraid , there is no source level debug with c-- , instead you can use  ollydbg debuger.

Quote from: habran on October 19, 2013, 08:16:43 PM
64 bit?

note well ,the back end is c-- compiler ver 0239 2005 , so c-- will not produce 64 bit.

I so not know about 64bit , but c-- can produce an object file that can be linked with masm linker ,but can
obj32 file linked with 64 bit linker ?
   

Emil_halim

hi all;

this time i have add c preprocessor  by using cpp exe of gcc.

so what it is good for ?

actually you can use define c macro with masm and c-- to make inline function style.

see this demo

/*************************************
*           Sphinx C--               * 
*                                    *
*       c preprocessor test          *
*                                    *
*         by Emil_halim              *         
*                                    *
*************************************/


#pragma option w32c       //create Windows console EXE.
#pragma option OS         //speed optimization
#jumptomain NONE          //just jump to main function

#includepath "D:\Ext_c--\winlib" 

#include <windows.h> 
#include <MSVCRT.H-->
 
#pragma option ia        //allow inserte asm instructions

#define GetRrandom(min, max) \
        EBX=max; EBX++; sub EBX,min  \
        rand(); div EBX; XCHG EAX,EDX; EAX+=min;   


#pragma option LST

^^
; #########################################################################

;  using c preprocessor  with masm code
;
; #########################################################################

#define addval(a,b)  mov eax,a add eax,b

; #########################################################################
^^

void main()
{
     
     srand( GetTickCount() );
     GetRrandom(12, 25);
     printf("%d\n",EAX);

     addval(30, 40);
     printf("%d\n",EAX);
           
     MessageBox(0,"","",0);
}

 

i will post the second release of Ext_c-- sooner.

enjoy coding masm % c--.

Emil_halim

Hi all,

also added  Equ masm directive , so Ext_c-- will understand it.

very simple Demo

/*************************************
*           Sphinx C--               * 
*                                    *
*       Equ directive test           *
*                                    *
*         by Emil_halim              *         
*                                    *
*************************************/


#pragma option w32c       //create Windows console EXE.
#pragma option OS         //speed optimization
#jumptomain NONE          //just jump to main function

#includepath "D:\Ext_c--\winlib" 

#include <windows.h> 
#include <MSVCRT.H-->
 
#pragma option ia        //allow inserte asm instructions

#pragma option LST

^^
; #########################################################################

;  using  masm equ directive
;
; #########################################################################


I_am_Ten   equ  0Ah
I_am_Zero  equ  0

Ten:
    mov eax, I_am_Ten
    ret

Zero:
    eax = I_am_Zero
    ret

; #########################################################################
^^

void main()
{
     
     
  ^  invoke Ten
     printf("%d\n",EAX);   
     
     call Zero
     printf("%d\n",EAX);   
           
     MessageBox(0,"","",0);
}
   

if you want to contribute , just test it and post any error you will found.

thanks.   

Emil_halim


Emil_halim

Hi all;

this time i will show you how to use labels with c--

the demo   ,self explanation.
=====================

/*************************************
*           Sphinx C--               * 
*                                    *
*      using labels with c--         *
*                                    *
*        By  Emil Halim              *
*          10-11-2013                *
*************************************/

#pragma option w32c       //create Windows console EXE.
#pragma option OS         //speed optimization
#jumptomain NONE          //just jump to main function

#includepath "D:\Ext_c--\winlib" 

#include <windows.h> 
#include <MSVCRT.H-->
 
#pragma option ia        //allow inserte asm instructions


#pragma option LST

// declare some c-- variable

byte xSrc = "This is a string, that serves for a variety of purposes, such as testing algos.";

long xNum = 20;

// declare some masm variable via labels

src19: db "1234567890123456789", 0
src20: db "12345678901234567890", 0

num1:  dd 10

// code with masm label

dumy:
   mov eax,1
   ret
   
/******************************************
  some functions will using data label
******************************************/
/***************
s > t >>>  > 0
s = t >>>  = 0
s < t >>>  < 0
***************/
int strcmp1(char *s, char *t)           // pure C code
{
   for( ;byte *s == byte *t; s++, t++)
   if (byte *s == '\0') return 0;
   return  DSBYTE[s] - DSBYTE[t];
}

/**********************
       Testing
**********************/
void main()
{
   
  // move label dumy address into EBX
  EBX = #dumy;
  EBX();         //call it via register
  printf("EAX is = %d\n",  EAX );
 
  call dumy      //call it directly
  printf("EAX is = %d\n",  EAX );
 
  // move lable dumy address into EBX
  MOV EAX,#dumy
  EAX();
  printf("EAX is = %d\n",  EAX );
 
  // compare EAX against label src20 address
  CMP EAX,src20
  CMP EAX,#src20
 
  // move label src20 address into EAX
  LEA EAX,DSWORD[src20]
  printf("str is = %s\n",  EAX );
 
  //compare variable xNum contains against EAX
  CMP EAX,xNum             //compiled to --> cmp eax,[401160h]
 
  // compare label num1 address against EAX
  CMP EAX,num1            //compiled to --> cmp eax,401164h
  CMP EAX,#num1           //compiled to --> cmp eax,401164h
 
  // compare label num1 contains against EAX
  CMP EAX,DSDWORD[num1]   //compiled to --> cmp eax,[401164h]
       
  printf("str#1 = str#2 , result = %d\n",  strcmp1(#src20, #src20) );
 
  printf("str#1 > str#2 , result = %d\n",  strcmp1(#src20, #src19) );
 
  printf("str#1 < str#2 , result = %d\n",  strcmp1(#src19, #src20) );
 
  MessageBox(0,"","",0);
 
}

 

enjoy coding masm & c--.