flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > FAT32 opening files Goto page Previous 1, 2 |
Author |
|
baldr 01 May 2013, 17:27
superos,
#DE is a fault, thus iret resumes execution of the faulting div. BTW #DE is caused not only with division by zero, div dx faults too. |
|||
01 May 2013, 17:27 |
|
superos 02 May 2013, 12:15
Hello,
at the end of the function I wrote: Code: pop es pop ds mov ax,1 sti iret I've been working. Worse, how will div bl or the other. |
|||
02 May 2013, 12:15 |
|
BAiC 02 May 2013, 13:00
the iret in the handler does, in fact, return to your code courtesy of exception 0 not having an error code. however, it pops data off the stack corresponding to an exception event resulting in an imbalanced stack.
the CS and FLAGS registers are popped from the stack so if you didn't push them prior to the call then whatever data was on the stack will be written to them. updating CS will cause a jump elsewhere, so your CS value had to have been the same as before. the FLAGS could be anything. in simplest terms: do not call an interrupt. it has its own issues. _________________ byte me. |
|||
02 May 2013, 13:00 |
|
BAiC 02 May 2013, 13:11
you have two options (potentially):
1) if your OS has task switching, terminate the task. 2) freeze the OS in the exception 0 handler. use a cli/jmp $. or hlt if it's available, _________________ byte me. |
|||
02 May 2013, 13:11 |
|
baldr 02 May 2013, 14:44
BAiC
Probably superos meant calls inside the fault handler (rysuj_kwadrat(), przesun_kursor, etc.) If that OS doesn't have task switching, it may simply terminate offending program and return to whatever has spawned that program. Even DOS is able to do this. ----8<---- superos, Those cli/sti in your handler are superfluous. Handler (in real-address mode) starts with interupts disabled, and iret restores flags from stack. Recovering from #DE is not an easy task. Most OSes treat it as program (programmer?) failure and kill it. While it's possible to decode faulting instruction and try to correct its operands, it's hard to make it reasonably (I mean that program will not fail due to corrections made). You may as well just skip it, like in the following code: Code: org 0x100 xor ax, ax mov es, ax mov word [es:0], handler mov word [es:2], cs div dx mov ah, 9 mov dx, [message] int 0x21 ret message dw not_signaled not_signaled db "#DE isn't signaled", 13, 10, "$" signaled db "Happily skipped 'div' instruction.", 13, 10, "$" handler: push bp mov bp, sp mov [cs:message], signaled add word [bp+2], 2; skip 'div dx'; it has two-byte opcode pop bp iret |
|||
02 May 2013, 14:44 |
|
BAiC 02 May 2013, 15:27
baldr: look at superos' previous post:
Quote: If I call it the "call" works fine, but if by "mov al, 0 div al" _________________ byte me. |
|||
02 May 2013, 15:27 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.