News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

NMI in real mode

Started by debaras, March 24, 2005, 08:44:11 PM

Previous topic - Next topic

debaras

A question i've wondered about for a long time:
(In real mode) When disabling interrupts for, say switching stacks, NMIs can still occur. where are CS:IP + flags stored?
For example:
cli
mov ss,ax
;-- INT 01 called - single step debug
mov sp,bx
sti

They can't be stored at SS:SP, it could be anywhere? Well it's to wonder if all my old programs worked just becaused i was lucky ;) ?

MichaelW

In real mode all interrupts use the stack in the same manner. In your example, the interrupt would not be called because the CPU specifically inhibits interrupts after SS is written to until the next instruction (which should be a move into SP) has executed.

http://www.masmforum.com/simple/index.php?topic=1014.0


eschew obfuscation

debaras

Thanks! i didn't know mov ss,.. disabled ints for the next instruction. So i guess that means that there is no need for cli/sti when moving the stack. I don't know why examples used to have cli/sti... Maybe it was different on the 486..(?)
I just understood something else: the only NMI is INT 02h. INT 01h isn't masked...
Sorry for posting in the wrong forum!

edit: small update, i couldn't resist to get my old 486 out of the dust and try. Ints are disabled after mov ss,.. also on 486; i just understood why the debugger always "slipped"  to the 2nd next instruction after a mov ss,.. (i used CodeView)
Lol 10 years later i 'solve' the question of "why the degugger slipped an instr after a mov ss,.."  :D (i was young when i programmed in asm)

Mark_Larson


  You have to have I believe 1024 bytes free on your stack any time an interrupt can occur.  I might be misremembering the number.  We had a customer once complain that his code only failed on Dell systems.  The problem was our video card handler used more of the stack and he didn't allocate enough for when software or hardware interrupts occur.

BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

tenkey

Quote from: debaras on March 24, 2005, 10:18:55 PM
Thanks! i didn't know mov ss,.. disabled ints for the next instruction. So i guess that means that there is no need for cli/sti when moving the stack. I don't know why examples used to have cli/sti... Maybe it was different on the 486..(?)

The earliest versions of the 8086 (the 8088 came later, I don't know if it had the same problem) did not disable the interrupts automatically.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8