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"
11 : "+D" (buf
), "+c" (len
) : "a" (ch
) : "memory");
14 static void strcpy(char *dst
, const char *src
)
22 static void printregs(const com32sys_t
*r
)
24 printf("eflags = %08x ds = %04x es = %04x fs = %04x gs = %04x\n"
25 "eax = %08x ebx = %08x ecx = %08x edx = %08x\n"
26 "ebp = %08x esi = %08x edi = %08x esp = %08x\n",
27 r
->eflags
.l
, r
->ds
, r
->es
, r
->fs
, r
->gs
,
28 r
->eax
.l
, r
->ebx
.l
, r
->ecx
.l
, r
->edx
.l
,
29 r
->ebp
.l
, r
->esi
.l
, r
->edi
.l
, r
->_unused
.l
);
34 unsigned int ax
,cx
,si
,t
;
35 com32sys_t inreg
,outreg
;
38 /* Test null system call */
39 inreg
.eflags
.l
= 0xffffffff;
40 inreg
.eax
.l
= 0x11110000;
41 inreg
.ecx
.l
= 0x22222222;
42 inreg
.edx
.l
= 0x33333333;
43 inreg
.ebx
.l
= 0x44444444;
44 inreg
.ebp
.l
= 0x55555555;
45 inreg
.esi
.l
= 0x66666666;
46 inreg
.edi
.l
= 0x77777777;
52 __com32
.cs_intcall(0x22, &inreg
, &outreg
);
56 memset(&inreg
, 0, sizeof inreg
);
57 memset(&outreg
, 0, sizeof outreg
);
58 strcpy(__com32
.cs_bounce
, "test.txt");
59 inreg
.eax
.w
[0] = 0x0006; // Open file
60 inreg
.esi
.w
[0] = OFFS(__com32
.cs_bounce
);
61 inreg
.es
= SEG(__com32
.cs_bounce
);
63 __com32
.cs_intcall(0x22, &inreg
, &outreg
);
67 si
= outreg
.esi
.w
[0]; /* File handle */
68 cx
= outreg
.ecx
.w
[0]; /* Block size */
69 ax
= outreg
.eax
.l
; /* File length */
72 /* We can only read 64K per call */
73 t
= ( ax
> 65536 ) ? 65536/cx
: (ax
+cx
-1)/cx
;
75 memset(&inreg
, 0, sizeof inreg
);
77 inreg
.ecx
.w
[0] = t
; /* Block count */
78 inreg
.eax
.w
[0] = 0x0007; // Read file
79 inreg
.ebx
.w
[0] = OFFS(__com32
.cs_bounce
);
80 inreg
.es
= SEG(__com32
.cs_bounce
);
82 __com32
.cs_intcall(0x22, &inreg
, &outreg
);
87 /* Print the buffer */
88 t
= (ax
< 65536) ? ax
: 65536;
89 p
= __com32
.cs_bounce
;