From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: interrupt wrapper Date: Sat, 10 Jan 1998 14:26:47 +0000 Organization: None Distribution: world Message-ID: References: <34B6DA1F DOT 42E68777 AT gold DOT com DOT br> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=iso-8859-1 Lines: 31 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Sérgio Vale e Pace writes: >Can somebody ou there tell me what is and what is the propose of the >interrupt wrappers, the out 0x20, 0x20 I already understand, but this >wrappers really escaped me, in a first look, they look just like a lot >of push and pop instructions that I really don't know why to do that. You have to do several things in an interrupt handler before you can start running normal C code. For starters, you have to push all the register values onto the stack and restore them before you exit the handler, because bad things would happen if your handler went around randomly changing register values in the middle of some other piece of code. Also, you need to set up some of the registers in the way gcc code is expecting, ie. with %cs, %ds, and %ss all containing the selector for your program, and %esp pointing at a valid stack within your address space. The interrupt routine will be called with a valid stack pointer in %ss:%esp, but that may be located anywhere at all, and the flat memory model code produced by gcc will fail miserably unless the stack lives in the same segment as the code and data. The process is really quite simple: you just have to be very careful not to use any registers until you have initialised them. For example you can't just load a selector value from any old memory address, because %ds may not be set correctly when the interrupt fires. But you know that %cs will be set (it has to be to run your code), so a %cs override is needed to access any memory at all until you have set up the %ds selector... -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ "Pigs use it for a tambourine" - Frank Zappa around the up vector. To roll clockwise or anticlockwise, rotate the up vector around the front vector. To pitch up or down, rotate the up and front vectors around the righthand vector (that can be generated whenever you need it, as the cross product of front and up). All of those rotations will work correctly no matter what orientation you are starting with, and without any nasty distortions along the wrong axis... >I have my camera as a special object which i navigate with. Im trying to >write yawCAMERA(CAMERA *cam, fixed angle); which should swing the camera >left & right. If you have a front and up vector for your camera, simply rotate the front vector around the up vector, by using get_vector_rotation_matrix() with your up vector, and applying the result to your front vector. -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ "Pigs use it for a tambourine" - Frank Zappa