The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: BigDaddy on December 22, 2004, 11:29:28 PM

Title: Pushing a zero after pushing DS
Post by: BigDaddy on December 22, 2004, 11:29:28 PM
I personally have only coded for small models, but I have some old example code that HLL's link to for bigger models.  These FAR procs tend to push DS (which seems reasonable) but then push a zero on top of DS.  What is the purpose of this, and will 32 bit code need the same treatment?
Title: Re: Pushing a zero after pushing DS
Post by: MichaelW on December 23, 2004, 05:41:32 AM
I would need more information to even understand your question, much less answer it. What HLL will be linking to this code? Can you post a complete example procedure?
Title: Re: Pushing a zero after pushing DS
Post by: BigDaddy on December 23, 2004, 04:05:50 PM
I'm referring to the entry point of the MASM routine, The part of the overhead code that preserves the stack frame, like:

push bp
mov bp,sp

push ds
xor ax,ax
push ax

;start yanking the arguments
etc....

I don't have a piece of code in front of me, but I seem to recall a RET 6, so it's more like the Pascal calling convention than C. 

I was thinking that the purpose of the zero was to serve as the offset on the FAR return, but that confuses me, somewhat, given that the real offset should have been pushed onto the stack by the calling program. 

I'll look around for the mystery code when I get home. 

Thanks,
Dan
Title: Re: Pushing a zero after pushing DS
Post by: BigDaddy on December 29, 2004, 06:17:21 PM
Sorry I haven't been able to get on the web to update this question.  When I looked at the source in question, again, I saw that I had made a couple of wrong assumptions about the program's purpose.  So, when I get the time, I'll start a new thread that gets the questions right, and includes the full source.