News:

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

Porting to nasm

Started by bcddd214, December 06, 2011, 09:21:19 PM

Previous topic - Next topic

bcddd214

I am trying to compile this code with nasm and greeting the following error.

/home/brads/test.asm:1: error: parser: instruction expected
/home/brads/test.asm:3: error: parser: instruction expected
/home/brads/test.asm:4: error: parser: instruction expected
/home/brads/test.asm:6: error: parser: instruction expected
/home/brads/test.asm:7: error: parser: instruction expected
/home/brads/test.asm:8: error: parser: instruction expected
/home/brads/test.asm:9: error: parser: instruction expected
/home/brads/test.asm:10: error: parser: instruction expected
/home/brads/test.asm:11: error: parser: instruction expected
/home/brads/test.asm:12: error: parser: instruction expected
/home/brads/test.asm:13: error: symbol `WINDESC' redefined
/home/brads/test.asm:13: error: parser: instruction expected
/home/brads/test.asm:15: error: parser: instruction expected
/home/brads/test.asm:21: error: parser: instruction expected
/home/brads/test.asm:25: error: parser: instruction expected
/home/brads/test.asm:43: error: symbol `curpos' redefined
/home/brads/test.asm:43: error: parser: instruction expected
/home/brads/test.asm:45: error: parser: instruction expected
/home/brads/test.asm:60: error: symbol `putchar' redefined
/home/brads/test.asm:60: error: parser: instruction expected
/home/brads/test.asm:62: error: parser: instruction expected
/home/brads/test.asm:74: error: expecting `)'
/home/brads/test.asm:75: error: expecting `)'
/home/brads/test.asm:76: error: expecting `)'
/home/brads/test.asm:77: error: expecting `)'
/home/brads/test.asm:78: error: expecting `)'
/home/brads/test.asm:92: error: symbol `makewin' redefined
/home/brads/test.asm:92: error: parser: instruction expected
/home/brads/test.asm:94: error: parser: instruction expected
/home/brads/test.asm:98: error: comma, colon or end of line expected
/home/brads/test.asm:101: error: symbol `exit' redefined
/home/brads/test.asm:102: error: symbol `main' redefined
/home/brads/test.asm:102: error: parser: instruction expected
/home/brads/test.asm:104: error: parser: instruction expected



TITLE The New DOS

.model      small
.stack      100h

WINDESC      STRUCT
         upperRow      BYTE   ?
         leftCol         BYTE   ?
         lowerRow      BYTE   ?
         rightCol         BYTE   ?
         foreColor      BYTE   ?
         backColor      BYTE   ?
WINDESC      ENDS

exit      MACRO
         mov            ax, 4C00h
         int            21h
         ENDM
         
.data
application   WINDESC         <05h, 05h, 15h, 45h, 07h, 10h>

.code

curpos      PROC
         push         bp
         mov            bp, sp
         push         ax
         push         bx
         push         dx
         
         mov            ax, 0200h
         mov            bh, 0
         mov            dx, [bp+4]
; interrupt
         int            10h
         
         pop            dx
         pop            bx
         pop            ax
         pop            bp
         ret            2
curpos      ENDP

putchar      PROC
         push         bp
         mov            bp, sp
         push         ax
         push         bx
         push         cx
         push         dx
         
; missing something here
         pop            dx
         pop            cx
         pop            bx
         pop            ax
         pop            bp
         ret            2
putchar      ENDP

makewin      PROC
         push         bp
         mov            bp, sp
         push         ax
         push         bx
         push         cx
         push         dx
         push         si
         
         mov            si, [bp+4]
         
         mov            ax, 0600h
         mov            bh, (WINDESC PTR[si]) .backColor
         mov            ch, (WINDESC PTR[si]) .upperRow
         mov            cl, (WINDESC PTR[si]) .leftCol
         mov            dh, (WINDESC PTR[si]) .lowerRow
         mov            dl, (WINDESC PTR[si]) .rightCol
;interrupt
         int            10h
         
         push         cx
         call         curpos
         
         pop            si
         pop            dx
         pop            cx
         pop            bx
         pop            ax
         pop            bp
         ret            2
makewin      ENDP

main      PROC
         mov            ax, @data
         mov            ds, ax
         
         mov            ax, OFFSET application
         push         ax
         call         makewin
         exit
main      ENDP

         end            main

bcddd214

It would appear that nasm does not ENDP ??

bcddd214

Never mind, I installed jwasm

mineiro

Different assemblers use different sintaxes , jwasm maintain compatibility with masm sintaxe (Irvine uses masm). So, you need get nasm manual, and make a correlation with masm manual to port your code to that assembler.
An assimilation of this is; you get one code to C++ and try to compile that code using Delphi.

dedndave

i recently converted a little bit of NASM code to MASM syntax
it wasn't that hard - at least for the little bit of code i did

1) PROC's in NASM have no ENDP
2) using data labels without brackets references the address of the label
3) using data labels with brackets references the data, itself

NASM:
        mov     edx,VarLabel1         ;EDX is loaded with the address of VarLabel1
        mov     eax,[VarLabel1]       ;EAX is loaded with the data at VarLabel1


MASM:
        mov     edx,offset VarLabel1  ;EDX is loaded with the address of VarLabel1
        mov     eax,VarLabel1         ;EAX is loaded with the data at VarLabel1


i think there are a few other differences regarding things like EXTERNDEF, etc
you'd have to look some of that up - try google'ing "nasm syntax"