News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Why does this pattern move down the stack and what it is good for?

Started by bugthis, April 27, 2023, 01:38:47 AM

Previous topic - Next topic

bugthis

I have written a small test program in DOS that pushs the values of the 4 registers AX, BX, CX, DX on the stack and pops them after that back to the registers.
See screenshot "debug.png" for the program.

1. When i test that program with DEBUX.EXE the stack looks good, but what is that "01 63 08 86 33" pattern, that moves down the Stack when the stack grows?
See screenshot "stack_grow.png".
I marked this pattern in red.

Each row shows the new changed stack at address 0863:FFF0 after a step.
The register values are marked in yellow. For easier recognition, i only marked 1 byte of each 16 bit register value.

2. Then there is another value, that is also moving down the stack, but its value is counting upwards. I marked that in green.

Is that pattern made and moved by DEBUG.EXE?
And is that counter made and incremented by DEBUG.EXE?

EDIT:
Sadly images had to be zipped. So here is the ASCII text of the memory dump after each step without colors:
           0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F               SP
0863:FFF0  00 00 09 01 00 00 63 08-0C 01 63 08 86 33 00 00     PUSH AX, FFFC
0863:FFF0  00 00 0C 01 00 00 0D 01-63 08 86 33 01 00 00 00     PUSH BX, FFFA
0863:FFF0  0D 01 00 00 0E 01 63 08-86 33 02 00 01 00 00 00     PUSH CX, FFF8
0863:FFF0  00 00 0F 01 63 08 86 33-03 00 02 00 01 00 00 00     PUSH DX, FFF8
0863:FFF0  10 01 63 08 86 33 04 00-03 00 02 00 01 00 00 00            , FFF6


Code was:

MOV AX, 0001
MOV BX, 0002
MOV CX, 0003
MOV DX, 0004
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AX, FF
MOV BX, FF
MOV CX, FF
MOV DX, FF
POP DX
POP CX
POP BX
POP AX
MOV AH, 4C
INT 21


_japheth

Quote from: bugthis on April 27, 2023, 01:38:47 AM
Is that pattern made and moved by DEBUG.EXE?
No, it's the cpu itself, caused by an INT 01.

Quote
And is that counter made and incremented by DEBUG.EXE?

No, it's actually the IP register - since the INT instruction stores IP CS Flags onto the stack.
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

bugthis

Quote from: _japheth on April 27, 2023, 04:45:20 PM
No, it's the cpu itself, caused by an INT 01.
...
No, it's actually the IP register - since the INT instruction stores IP CS Flags onto the stack.
Ah, i see. It's the CPU's Debug Exception.

According to page 3A 6-21
https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.pdf

Thank you for your clarification.  :thumbsup: