4 #define NULL ((void *)0)
5 int printf(const char *, ...);
8 static inline void memset(void *buf
, int ch
, unsigned int len
)
10 asm volatile ("cld; rep; stosb":"+D" (buf
), "+c"(len
):"a"(ch
):"memory");
13 static void strcpy(char *dst
, const char *src
)
21 static void printregs(const com32sys_t
* r
)
23 printf("eflags = %08x ds = %04x es = %04x fs = %04x gs = %04x\n"
24 "eax = %08x ebx = %08x ecx = %08x edx = %08x\n"
25 "ebp = %08x esi = %08x edi = %08x esp = %08x\n",
26 r
->eflags
.l
, r
->ds
, r
->es
, r
->fs
, r
->gs
,
27 r
->eax
.l
, r
->ebx
.l
, r
->ecx
.l
, r
->edx
.l
,
28 r
->ebp
.l
, r
->esi
.l
, r
->edi
.l
, r
->_unused_esp
.l
);
33 unsigned int ax
, cx
, si
, t
;
34 com32sys_t inreg
, outreg
;
37 /* Test null system call */
38 inreg
.eflags
.l
= 0xffffffff;
39 inreg
.eax
.l
= 0x11110000;
40 inreg
.ecx
.l
= 0x22222222;
41 inreg
.edx
.l
= 0x33333333;
42 inreg
.ebx
.l
= 0x44444444;
43 inreg
.ebp
.l
= 0x55555555;
44 inreg
.esi
.l
= 0x66666666;
45 inreg
.edi
.l
= 0x77777777;
51 __com32
.cs_intcall(0x22, &inreg
, &outreg
);
55 memset(&inreg
, 0, sizeof inreg
);
56 memset(&outreg
, 0, sizeof outreg
);
57 strcpy(__com32
.cs_bounce
, "test.txt");
58 inreg
.eax
.w
[0] = 0x0006; // Open file
59 inreg
.esi
.w
[0] = OFFS(__com32
.cs_bounce
);
60 inreg
.es
= SEG(__com32
.cs_bounce
);
62 __com32
.cs_intcall(0x22, &inreg
, &outreg
);
66 si
= outreg
.esi
.w
[0]; /* File handle */
67 cx
= outreg
.ecx
.w
[0]; /* Block size */
68 ax
= outreg
.eax
.l
; /* File length */
71 /* We can only read 64K per call */
72 t
= (ax
> 65536) ? 65536 / cx
: (ax
+ cx
- 1) / cx
;
74 memset(&inreg
, 0, sizeof inreg
);
76 inreg
.ecx
.w
[0] = t
; /* Block count */
77 inreg
.eax
.w
[0] = 0x0007; // Read file
78 inreg
.ebx
.w
[0] = OFFS(__com32
.cs_bounce
);
79 inreg
.es
= SEG(__com32
.cs_bounce
);
81 __com32
.cs_intcall(0x22, &inreg
, &outreg
);
86 /* Print the buffer */
87 t
= (ax
< 65536) ? ax
: 65536;
88 p
= __com32
.cs_bounce
;