Subj : NASM segment registers- again To : Robin Sheppard From : Jasen Betts Date : Sun Oct 21 2001 11:11 pm Hi Robin. 21-Oct-01 04:21:44, Robin Sheppard wrote to All RS> This is a re-post of a message I posted recently. I didn't get RS> any replies, so was wondering if it even got out. On the RS> assumption that it probably didn't, I'm posting it again. ------- it did. I don't have a good answer but I'll try. RS> Does anyone know how to load segment registers at runtime using RS> NASM, when generating COFF output? no. RS> Specifically, I'm trying to port some 16-bit timer-handler code I RS> wrote so it'll run under DJGPP. The assembly code has three RS> functions, _hooktimer, _unhooktimer, and newtimer. The first two RS> are global symbols, so my C code can use them to (you guessed it) RS> hook and unhook the timer. The newtimer procedure is the actual RS> interrupt handler, and all it does currently is send an RS> end-of-interrupt, execute STI, and exit. if you're using C you may be able to use signal instead of messing with interrupts... RS> It's supposed to increment a global variable called _count, but RS> since the function is asynchronous, I can't rely on the value of RS> DS; I have to load it myself. If I don't, it'll merrily increment RS> random memory locations until my machine crashes. This is what I RS> can't figure out how to do. if you need the names of the sections check out the assembler code egnerated by gpp (it'll be AT&T syntax but should be readable) OTOH nm some_unstripped.exe should list all the names (labels) in that exe... RS> The only way I can think of to get around this is to create an RS> alias data descriptor for my code segment, and use that to write RS> the value directly into my code segment at runtime. Not only does RS> this seem like a kludge, but it also seems to be bad programming RS> practice. Isn't there some mechanism similar to RS> mov ax, DGROUP I guess you've been through the NASM manual and the djgpp into tree a few times already... doesn't DJGPP support an "interrupt" function-type, if it does compile one to assembler and see how it's built. OTOH I'm told that djgcc uses tiny model with DS,CS, and SS all pointing to the same memory (if not the same segment descriptor) and they never change, I'm not sure how the DPMI stub handles interrupts... If nothing works check the ALLEGRO source it'll have an example of interrupts for shure. -=> Bye <=- --- * Origin: Every time I think I know where it's at, the move it. (3:640/531.42) .