Assembler question: examining the stack in debug

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
16,250
Reaction score
19,740
Location
Centurion
I wrote a small program to examine the stack as it grows down. (16bit 8086)

In debug, the value of DS is 11BF which is of course 16 bits.

When I trace in debug the command PUSH DS I get the following when examining the stack, why is the stack now filled with three words / 3 x 16bits instead of one word ? As can seen before the trace the stack is 0 DUPpped and after PUSH DS it contains three words.

@cguy

stack.PNG
 
I think I answered my own question.

debug does not initialize the program until the first instruction is ran

I changed the first instruction to mov ax,ax (was push ds) and now there are two words in the top of the stack segment after the trace of the first instruction (mov ax,ax)
 
This takes me back. Used to do loads of asm programming back on the 8088.

Remember Ralph Brown's interrupt list :)
http://ctyme.com/rbrown.htm

I remember when it was the only way to do fast graphics.

I also remember the shock at seeing an array with 16 byte elements being indexed via a mul instead of a shl.
 
@cguy @gregmcc

I want to do some more tests, but do you think that the program only properly initializes after the first instruction in debug and that the 2 extra values in the stack segment are for the Program Segment Prefix (it's an exe)
 
@cguy @gregmcc

I want to do some more tests, but do you think that the program only properly initializes after the first instruction in debug and that the 2 extra values in the stack segment are for the Program Segment Prefix (it's an exe)

It's going to initialize before the first instruction is executed, however, between pressing step on an unstarted program and the first instruction, there could definitely be some setup. The mysterious value that appears pushed may even be the return address back to the debugger or some such. You can try debug the debugger to see. :-)
 
Top
Sign up to the MyBroadband newsletter
X