NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: flyhigh427 on July 22, 2011, 03:03:02 PM
-
hey
good morning
nasm gives me an error if i try this . stacksize to =200h
STACKSIZE = 200h
if they used tasm how do i change this?
model small
.386
.stack STACKSIZE
.code
and thank yall for your help i know you all have stuff to do to again thanks
-
is it alright to use EQU in stacksize equ 200h
-
i didnt think u could use if else in asembly?
GenericInt macro function, subfunction
ifb <subfunction>
mov ah,function
else
mov ax,(function SHL 8) OR (subfunction AND 0ffh)
endif
endm
DosInt macro function, subfunction
GenericInt <function>,<subfunction>
int DOS_INT
endm
-
Yeah, use "equ" instead of "=".
From there on, the questions become a little more complicated. The Tasm code looks like it's making an MZ executable. You'd use "-f obj" for Nasm... and a linker. This would have several advantages. You can have a full 64k for code, another full 64k for data (I'm not sure where the stack goes in "model small" - may be shared with data?). Your entrypoint can be anywhere, doesn't have to be at the top of your file. And you can link multiple modules together. If you don't need any of those things, it's a lot easier (IMO) to ditch all that cruft and just make a .com file!
If you need (or want) "-f obj", the Nasm syntax for the stack is:
segment stack stack
resb STACKSIZE
The first "stack" is just a name, and could be anything. The second "stack" is an attribute, and Nasm needs it to know to tell the linker that this is a stack segment. The example in the Friendly Manual shows setting up ss and sp, but dos does this for us and it is not necessary - I don't know why it's in there. You do need to set up ds, and es if you need it - dos does not do this for us in an .exe (a 16-bit .exe, that is).
"if" and "else" are not machine instructions. Tasm has a "built-in macro" (not really a "macro" if it's built-in) to handle this - Nasm would require a separate macro. However, this particular "if" and "else" are used within a macro. The Nasm equivalents would be "%if" and "%else", but the syntax would have to be different.
If I understand "GenericInt", it accepts either one or two parameters. If just one, it puts it in ah. If two, it puts one in ah and the other in al (but combines 'em into ax). I can attempt this in Nasm, but it "hides away" stuff you should "see", IMO. You're better off without it! Give a yell if you want to use it - I think I see how it would go...
Best,
Frank