;***************************************************** ;---------------------- STACK FIX -------------------- ;***************************************************** STACK_FIX PROC NEAR MOV BX, [SI+2] ; Move the content of si+2 into bx MOV LOC, SP; save the location of stack pointer MOV SP, 500H; move to a clean memory location ADD SP, CX ; CX initially = 0 This counts up so i dont overwrite what I have pushed on the stack PUSH BX ; stack goes down 2 INC CX; I increment cx twice so on the next run bx will be pushed to memory location 500, then it will run again going to 502,504,506 ect INC CX MOV SP,LOC; mov the stack pointer back the original memory location RET STACK_FIX ENDP ********************************************************* Am I not allowed to do this? I've been working on this for 8 hours straight. I then later call a procedure that pops the info off the stack starting at 500h. It doesn't return the values that were in bx that i pushed on the stack. thanks
When you push, SP is decremented before the value is actually moved onto the stack. Your value is hence at 0x4FE. I don't understand the part of your code that deals with cx. If you do not ever save it, where does its value come into effect?
I use the CX register to account for the stack pointer moving down. Yes, On the first run my SP goes to 04fe. The next run CX is 2. So SP will be 0502 then after the push Bx it will be at 0500. The next run CX=4 so SP=0504. The Push BX will move SP 0502. If I didn't increment CX I would keep over writing my content. So when I want to look at these values later I will move my SP back to 04FE. Then POP the values until CX=0. I am pushing 2 numbers onto the stack. So imagine my stack to look like this. 0508:3838 0506:3737 0504:3131 0502:3434 0500:3333 04FE:3535 When I try to POP these values later, I don't see anything resembling numbers in ASCII. What's that?
It looks like it should work. You need to determine that your CX value is not being overwritten by other parts of your program, and that you are correctly loading your content into BX.