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,573 of 4,675    |
|    Paul Edwards to Terje Mathisen    |
|    Re: serial port    |
|    11 Apr 23 18:29:04    |
      From: mutazilah@nospicedham.gmail.com              On Wednesday, April 12, 2023 at 3:25:01 AM UTC+8, Terje Mathisen wrote:              > at this point I re-enable all other interrupts              Actually, that made me rethink - maybe it is more straightforward to:              Do this from C code, to signal that I am interested in TBE:              outb port2, tbemask ; enable transmit buffer empty (only)              Disable all interrupts (cli) from C code as well              Do this from C code:              outb port1, transmit_byte              And at this point, if the byte is transmitted very quickly,       the UART knows that it needs to do an interrupt, but       interrupts are temporarily disabled, so it knows that it       needs to queue the interrupt, not discard it.              And then I call this assembler:              xxx:       hlt ; this could get interrupted by timer interrupts and       then processing continues so we need a jmp       jmp xxx              And actually, even that can go into a function called halt_loop(),       called by C.              And then I can have this generic assembler routine:              gotint: ; this is the interrupt address installed by C caller       add esp, 12 ; we don't return to the previous instruction, which was hlt       instead we skip over the return address, segment and flags              Actually, no I can't. They need to be combined.              sti       xxx:       hlt ; this could get interrupted by timer interrupts and       then processing continues so we need a jmp       jmp xxx              gotint: ; this is the interrupt address installed by C caller       add esp, 12 ; we don't return to the previous instruction, which was hlt       instead we skip over the return address, segment and flags       sti ; interrupts will have been disabled automatically. need to reenable       ret              Possibly take that sti out and do it from C, as C will have       done a call to disable interrupts, so this would be a good match.              And this is put back into C code:              outb port2, oldmask ; restore previous interrupt mask (everything disabled)              So down to just 5 assembler instructions.              That's probably neat. And yes, I know it is inefficient.              BFN. Paul.              --- 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