Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - setregs() set register values http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 setregs()           Set register values
------------------------------------------------------------------------------
 Declaration
   system.hdr

 Syntax
   proc setregs extern

 Arguments
   None.

 Return
   None.

 Description
   The setregs() function sets the processor register values according
   to the values stored in the __regs global system structure, except
   for the cs, ip and bp registers.

   Use this function with extreme care. Setting the registers (especially
   ds and ss) to accidental values is likely to result in program misbehavior
   or system crash. Always set up the __regs structure with current register
   values by calling the getregs() function, then change the appropriate
   members of __regs, finally call setregs().

 Example
   #define EXAMPLE_SYSTEM
   #include example.hdr

   // This example switches to drive A: and displays the number of logical
   // drives. Functionally it is identical to the selectdrive() procedure.
   // The code demonstrates the correct use of getregs(), setregs(),
   // and doscall().
   
   proc Test_setregs
   getregs()           // update __regs structure with current register values
   
   // Set the required register values in the __regs structure.
   // There must be no other code between the calls to getregs() and setregs().
   __regs.dx := 0      // drive A:
   __regs.ax := 0x0e00 // select drive
   
   setregs()           // set processor registers according to __regs
   doscall()           // issue int 21h call immediately after setregs() call
   getregs()           // update __regs immediately after the doscall() call
   
   ? "Number of logical drives is", istr( __bregs.al )
   endproc

   proc main
   Test_setregs()
   endproc

See Also: __bregs __regs doscall() getregs()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson