News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

convert c++ to masm

Started by ragdog, May 23, 2010, 10:39:57 AM

Previous topic - Next topic

ragdog

Sorry

I have test this 2 ways and this works not in my example

Can you tell me how did you created this page?

Only what works if this with "mov"

clive

I just used a very trivial ASM file, for which I showed the LST file generated by

ML -c  -Fl  test16.asm

using MASM 6.15

TEST16.ASM
        .386
        .MODEL FLAT

        .DATA

OutBuf          dd      100h dup(?)
OutBufSize      dd      $-OutBuf

        dd      SIZEOF OutBuf

        .CODE

        END
It could be a random act of randomness. Those happen a lot as well.

clive

Expanding the test code a little further, to show SIZEOF going into a register. I think sizeof() is a macro/library function which I am not using. Just stock MASM.

ml  -c  -coff  -Fl  test17.asm

TEST17.ASM
        .386
        .MODEL FLAT

        .DATA

        db      1234 dup(0CCh) ; some junk to move the origin

OutBuf          dd      100h dup(?)
OutBufSize      dd      $-OutBuf

        dd      SIZEOF OutBuf

        .CODE

        mov     eax, SIZEOF OutBuf

        lea     ebx,OutBuf
        lea     ebx,OutBufSize
        mov     ebx,offset OutBuf
        mov     ebx,offset OutBufSize

        END


TEST17.LST (1st Page)
Microsoft (R) Macro Assembler Version 6.15.8803     05/24/10 12:41:56
test17.asm      Page 1 - 1


        .386
        .MODEL FLAT

00000000         .DATA

00000000  000004D2 [         db      1234 dup(0CCh) ; some junk to move the origin
    CC
   ]

000004D2  00000100 [ OutBuf          dd      100h dup(?)
    00000000
   ]
000008D2 00000400 OutBufSize      dd      $-OutBuf

000008D6  00000400         dd      SIZEOF OutBuf

00000000         .CODE

00000000  B8 00000400         mov     eax, SIZEOF OutBuf

00000005  8D 1D 000004D2 R         lea     ebx,OutBuf
0000000B  8D 1D 000008D2 R         lea     ebx,OutBufSize
00000011  BB 000004D2 R         mov     ebx,offset OutBuf
00000016  BB 000008D2 R         mov     ebx,offset OutBufSize

        END
It could be a random act of randomness. Those happen a lot as well.

ragdog

Ok Thanks for your help and time :U

I use this with "mov BufSize,sizeof OutBuf"

Greets,

clive

No problem.

Also if you want to look at code generated by a Microsoft C/C++ compiler, you can use the -FAcs option which generates a .COD file with ASM/C translations.

-Clive
It could be a random act of randomness. Those happen a lot as well.