What is an ideal Windows 98 laptop? - Assembly Coding

Discussion in 'Off Topic Discussion' started by ma777, Oct 1, 2015.

  1. ma777

    ma777 Peppy Member

    Joined:
    Jan 15, 2008
    Messages:
    337
    Likes Received:
    20
    ;*****************************************************
    ;---------------------- 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
     
  2. LeHaM

    LeHaM Site Soldier

    Joined:
    May 5, 2013
    Messages:
    2,634
    Likes Received:
    292
    tried hyper-v?
     
  3. sp193

    sp193 Site Soldier

    Joined:
    Mar 28, 2012
    Messages:
    2,217
    Likes Received:
    1,052
    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?
     
  4. ma777

    ma777 Peppy Member

    Joined:
    Jan 15, 2008
    Messages:
    337
    Likes Received:
    20
    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?
     
  5. sp193

    sp193 Site Soldier

    Joined:
    Mar 28, 2012
    Messages:
    2,217
    Likes Received:
    1,052
    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.
     
sonicdude10
Draft saved Draft deleted
Insert every image as a...
  1.  0%

Share This Page