having trouble preserving flags through IRET
Posted: Sat Mar 14, 2009 10:53 pm
I've abandoned trying to keep Socks in 512 bytes, which has allowed me to add a good number of features I couldn't have before. One of these features I'm struggling with is my system API ISR returning with the Carry or Zero flags set. I can't seem to get the flags past the IRET opcode, no matter what I try. I'm guessing I'm using the wrong stack offset, but I've checked the numbers several times.
Here's what I have (16-bit code):
My readFile function worked just fine (it successfully read folders from the disk) before I realized that the flags weren't being returned properly, but now it seems to think that there's always a disk read error, even though Bochs says there aren't. I'm pretty sure that I'm just doing something stupid. Could someone please tell me what it is?
Here's what I have (16-bit code):
Code: Select all
paramEDI equ BP+ 0
paramESI equ BP+ 4
paramEBP equ BP+ 8
paramESP equ BP+12
paramEBX equ BP+16
paramEDX equ BP+20
paramECX equ BP+24
paramEAX equ BP+28
intIP equ BP+32
intCS equ BP+34
intEF equ BP+36
socksISR:
pushad
mov bp, sp
;; Snip out calling the functions, they work correctly
;; I've very thoroughly tested them and they leave
;; SP and BP exactly as they were.
pushf
and byte [intEF], 0xBE
popf
pushf
jnc .noCarry
or byte [intEF], 0x01
.noCarry:
popf
jnz .noZero
or byte [intEF], 0x40
.noZero:
;; I've also tried this with the same results:
;; lahf
;; and ah, 0x41
;; or [intEF], ah
mov sp, bp
popad
iret