I came across some DJGPP code and tried it in Pascal and it works! 3 lines and you can set pointers directly and use them without crashing. Works great especially for graphics since you won't need to set the segment registers :) The C code was written by Emmanuel Lagare with help by Brennan Underwood.
Here's the GPC code:
TYPE TDWord = Cardinal(32); TWord = Cardinal(16); PByte = ^TByte; TByte = Cardinal(8);
TDPMIRegs = RECORD EDI, ESI, EBP, Rsvd, EBX, EDX, ECX, EAX : TDWord; Flags, ES, DS, FS, GS, IP, CS, SP, SS : TWord; END;
VAR Foo : PByte; DJBase : ASMName '__djgpp_base_address' TDWord;
PROCEDURE djgpp_nearptr_enable; ASMName '__djgpp_nearptr_enable';
PROCEDURE djgpp_nearptr_disable; ASMName '__djgpp_nearptr_disable';
PROCEDURE SimRMI( aInt : TWord; VAR aRegs : TDPMIRegs ); ASMName '__dpmi_int';
VAR Regs : TDPMIRegs;
PROCEDURE SetMode( aMode : TWord ); BEGIN Regs.EAX := aMode; SimRMI( $10, Regs ); END;
BEGIN djgpp_nearptr_enable;
TDWord( Foo ) := $A0000 + (-DJBase);
SetMode( $13 );
asm( 'movl $0x0F0F0F0F, %eax' ); asm( 'movl %0, %%edi' : '=m' (Duh) ); asm( 'addl $4000, %edi' ); asm( 'movl %eax, (%edi)' );
ReadLn;
SetMode( 3 );
djgpp_nearptr_disable; END.
See ya! Orlando Llanes
"Hey, we all did the drug thing, we all did the money thing, and eventually you find out that none of that stuff fixes anything, and we have nowhere else to go except to evolve spiritually and intellectually" -- Meredith Brooks
"Look out fo' flyeeng feet" O__/ a010111t@bc.seflin.org /|____. O <__. /> / \ ____________|_________ http://ourworld.compuserve.com/homepages/Monkey414
On Thu, 15 Jan 1998, Orlando Llanes wrote:
asm( 'movl $0x0F0F0F0F, %eax' ); asm( 'movl %0, %%edi' : '=m' (Duh) );
Thanks Chief for the correction! Sorry everybody! Change Duh above to Foo :} I use Duh a lot, I forgot to change it to the politically correct Foo :P
See ya! Orlando Llanes
"Hey, we all did the drug thing, we all did the money thing, and eventually you find out that none of that stuff fixes anything, and we have nowhere else to go except to evolve spiritually and intellectually" -- Meredith Brooks
"Look out fo' flyeeng feet" O__/ a010111t@bc.seflin.org /|____. O <__. /> / \ ____________|_________ http://ourworld.compuserve.com/homepages/Monkey414