Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 4,576 of 4,675    |
|    Andrew Cooper to Paul Edwards    |
|    Re: serial port    |
|    13 Apr 23 13:17:34    |
      From: andrew@nospicedham.cam.ac.uk              On 13/04/2023 12:05 pm, Paul Edwards wrote:       > / enable interrupts and then halt until interrupt hit       > _hltintgo:       > sti       > hloop:       > / I believe hlt will be interrupted by other interrupts, like       > / the timer interrupt, so we need to do it in a loop       > hlt       > jmp hloop       > _hltinthit:       > / remove return address, segment and flags from the stack as we       > / do not intend to return to the jmp following the hlt instruction       > / that was likely interrupted       > add %esp, 12       > / note that interrupts will be disabled again (I think) by virtue       > / of the fact that an interrupt occurred. The caller would have       > / disabled interrupts already, so we are returning to the same       > / disabled state.       > ret              This is why things get stuck.              The first time through, you hlt with interrupts enabled, so will wake up       on the fist interrupt.              But when you loop, you'll hlt again, this time with interrupts disabled,       and will never ever wake up again (other than for an NMI).              Your loop needs to read:              _hltintgo:        sti        hlt        cli        jmp _hltintgo       _hltinthit:        ...              to make things work as you intend.              sti;hlt as a pair is important for getting the blocked-by-STI shadow to       cover you into the hlt state, but it only works on the rising edge of       IF, so you need to explicitly clear interrupts in order to make the       sti;hlt on the second loop iteration work.              ~Andrew              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca