Can't get out of routine

Programming, for all ages and all languages.
Post Reply
smoothCoder
Member
Member
Posts: 43
Joined: Sat Aug 28, 2010 10:32 pm

Can't get out of routine

Post by smoothCoder »

Code: Select all

;here calls work fine
call bermuda_routine
mov byte [0b8000h], "A"
jmp $

stupid_routine:
mov byte [0b8002h], "B"
ret

bermuda_routine:
.........
mov byte [0b8004h], "C"
call stupid_routine
mov byte [0b8006h], "D"
ret
output: " BCD" and infinite loop
smoothCoder
Member
Member
Posts: 43
Joined: Sat Aug 28, 2010 10:32 pm

Re: Can't get out of routine

Post by smoothCoder »

I have printed the [RSP] memory in the begining of the routine and at the end, and the saved RIP has not changed.

And here go another weird example:

Code: Select all

;here calls work fine
call bermuda_routine
mov byte [0b8000h], "A"
mov byte [0b8000h], "A" ;repeating this instruction make the code to print the expected: "ABCD"
jmp $

stupid_routine:
mov byte [0b8002h], "B"
ret

bermuda_routine:
.........
mov byte [0b8004h], "C"
call stupid_routine
mov byte [0b8006h], "D"
ret


PD: Ok. Definitively the omited code in the routine is the responsable, but still appears illogical to me. The RSP is not modified nor the [RSP].
smoothCoder
Member
Member
Posts: 43
Joined: Sat Aug 28, 2010 10:32 pm

Re: Can't get out of routine SOLVED

Post by smoothCoder »

Ok. Finaly resolved. I was searching the error in the wrong place-in the STACK. But the error was that an instruction modified the address part of the "mov byte [0b8000h], 'A'" instruction. So the char was writen somewhere but not in the screen and the loop was the normal execution of the "jmp $".
Post Reply