Author Topic: is this a Variable problem  (Read 10412 times)

Offline flyhigh427

  • Jr. Member
  • *
  • Posts: 60
is this a Variable problem
« on: July 22, 2011, 03:03:02 PM »
hey 
good morning

nasm gives me an error if i try this .   stacksize to =200h 
Code: [Select]

STACKSIZE        = 200h
if they used tasm how do i change this?
Code: [Select]
        model small
        .386
        .stack  STACKSIZE
        .code

and thank yall for your help i know you all have stuff to do to again thanks

Offline flyhigh427

  • Jr. Member
  • *
  • Posts: 60
Re: is this a Variable problem
« Reply #1 on: July 22, 2011, 03:12:47 PM »
is it alright to use EQU in stacksize equ 200h

Offline flyhigh427

  • Jr. Member
  • *
  • Posts: 60
Re: is this a Variable problem
« Reply #2 on: July 22, 2011, 03:38:04 PM »
i didnt think u could use if else in asembly?

Code: [Select]


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



Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: is this a Variable problem
« Reply #3 on: July 22, 2011, 05:51:45 PM »
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:

Code: [Select]
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