flat assembler
Message board for the users of flat assembler.

Index > Main > Error msg address on stack, but how?

Author
Thread Post new topic Reply to topic
Alan Illeman



Joined: 12 Mar 2005
Posts: 4
Location: Toronto. Canada.
Alan Illeman 14 Mar 2005, 11:52
In ../source/dos/modes.inc

real32:
mov ax,7202h
push ax
popf
pushf
pop bx
cmp ax,bx
je processor_ok
call init_error
db 'required 80386 or better',24h
processor_ok:

My question is how does the address of the error msg get on the
stack? It is used by the call to init_error (see "pop dx" in the call)
yet it is declared, as shown above, after the call.

tia
Alan
Post 14 Mar 2005, 11:52
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8394
Location: Kraków, Poland
Tomasz Grysztar 14 Mar 2005, 13:37
The CALL instruction stores on the stack the address of the instruction that follows it, and then the RET instruction pops that value from the stack and continues execution from that point - this way calling the subroutines works.

In this case CALL is used differently, since the called routine never return control back, and there are no instructions defined after the CALL, but data (error message). So CALL stores on the stack the address of that data as if it was the next instruction.
Post 14 Mar 2005, 13:37
View user's profile Send private message Visit poster's website Reply with quote
Alan Illeman



Joined: 12 Mar 2005
Posts: 4
Location: Toronto. Canada.
Alan Illeman 14 Mar 2005, 23:38
Yes of course, for a non-returning call. Neat trick
that I didn't think through. Thanks.

While I have your attention <grin> does your
macro implentation include a variable number
of arguments? - like the 'vararg' in Masm.

..and a similiar 'vararg' for writing e.g. a 'printf'
function in asm?

Best Wishes.
Alan

p.s. I was weaned on Tasm and very much like what
I see in Fasm so far.
Post 14 Mar 2005, 23:38
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8394
Location: Kraków, Poland
Tomasz Grysztar 15 Mar 2005, 04:40
Yes, look in the section 2.3.3 of fasm's manual. My general advice for you is to read through all the materials from Documentation page, also the excellent vid's guide to preprocessor (the part of Tajga Tutorial).
Post 15 Mar 2005, 04:40
View user's profile Send private message Visit poster's website Reply with quote
Alan Illeman



Joined: 12 Mar 2005
Posts: 4
Location: Toronto. Canada.
Alan Illeman 16 Mar 2005, 23:19
Thanks Privalov.
I found it in the source e.g. CDECL.INC

Best Wishes,
Alan
Post 16 Mar 2005, 23:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.