Mail Archives: djgpp/1999/06/03/12:55:35.1
Another problem is that "dosmemput" is only being used to copy four
bytes, whereas there should be six... however, there is still the "pop
bx" and the "iret" to be fixed *really* - I even tried it. Your code
crashed my machine spectacularly, but the following code works fine:
#include <stdio.h>
#include <go32.h>
#include <dpmi.h>
int main()
{
unsigned char asmroutine[] = {0x89, 0xE5, 0x8B, 0x46,
0x04, 0x05, 0x13, 0x00, 0xCB};
int stack[1];
/* mov bp, sp
* mov ax, [bp+4]
* add ax, 13h
* retf
*/
int sel = 0, seg = 0;
__dpmi_regs r;
seg = __dpmi_allocate_dos_memory(2, &sel);
dosmemput(asmroutine, 9, (seg * 16));
memset(&r, 0, sizeof(r));
r.x.cs = seg;
/* I'm not sure about the stack[0] << 8 part, but it shouldn't matter
*/
stack[0] = 0x100;
__dpmi_simulate_real_mode_procedure_retf_stack(&r, 2, stack);
printf("Value of ax now: 0x%s\n", itoa(r.x.ax, NULL, 16));
}
__________________________________________________________
*** davmac - sharkin'!! davmac AT iname DOT com ***
my programming page: http://yoyo.cc.monash.edu.au/~davmac/
- Raw text -