Skip to content

Instantly share code, notes, and snippets.

@pinterior

pinterior/480.c Secret

Created Oct 1, 2021
Embed
What would you like to do?
#include <stdio.h>
#include <dos.h>
typedef unsigned char uint8_t;
void check_b(uint8_t far *p) {
uint8_t o = *p;
*p = ~o;
if (*p == o) {
printf(" [%02x]", o);
} else {
*p = o;
printf(" %02x", o);
}
}
void check(uint8_t far *p) {
int i;
printf("%04x:%04x:", FP_SEG(p), FP_OFF(p));
for (i = 0; i < 8; ++i) {
check_b(p + i);
}
printf("\n");
}
int main(int argc, char *argv[]) {
int i, j;
unsigned char far *d0, far *d8, far *e0, far *e8, far *f8;
unsigned char o480, o404;
d0 = MK_FP(0xd000, 0);
d8 = MK_FP(0xd800, 0);
e0 = MK_FP(0xe000, 0);
e8 = MK_FP(0xe800, 0);
f8 = MK_FP(0xf800, 0);
o404 = inp(0x404);
printf("Original 404h: %02x\n", o404);
o480 = inp(0x480);
printf("Original 480h: %02x\n", o480);
for (j = 0; j < 2; ++j) {
outp(0x404, j << 7);
for (i = 0; i < 4; ++i) {
outp(0x480, i);
printf("\n[404h = %02x, 480h = %02x]\n", j << 7, i);
check(d0);
check(d8);
check(e0);
check(e8);
check(f8);
}
}
outp(0x480, o480);
outp(0x404, o404);
return 0;
}
Original 404h: 00
Original 480h: 00
[404h = 00, 480h = 00]
d000:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
d800:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
e000:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
e800:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
f800:0000: [07] [01] [73] [00] [00] [00] [00] [00]
[404h = 00, 480h = 01]
d000:0000: [00] [00] [00] [01] [00] [00] [20] [06]
d800:0000: 01 ff 42 4f 4f 54 a8 00
e000:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
e800:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
f800:0000: [07] [01] [73] [00] [00] [00] [00] [00]
[404h = 00, 480h = 02]
d000:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
d800:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
e000:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
e800:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
f800:0000: 00 00 00 00 00 00 00 00
[404h = 00, 480h = 03]
d000:0000: [00] [00] [00] [01] [00] [00] [20] [06]
d800:0000: 01 ff 42 4f 4f 54 a8 00
e000:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
e800:0000: [ff] [ff] [ff] [ff] [ff] [ff] [ff] [ff]
f800:0000: 00 00 00 00 00 00 00 00
[404h = 80, 480h = 00]
d000:0000: 00 00 00 00 00 00 00 00
d800:0000: 00 00 00 00 00 00 00 00
e000:0000: 00 00 00 00 00 00 00 00
e800:0000: 00 00 00 00 00 00 00 00
f800:0000: [07] [01] [73] [00] [00] [00] [00] [00]
[404h = 80, 480h = 01]
d000:0000: 00 00 00 00 00 00 00 00
d800:0000: 00 00 00 00 00 00 00 00
e000:0000: 00 00 00 00 00 00 00 00
e800:0000: 00 00 00 00 00 00 00 00
f800:0000: [07] [01] [73] [00] [00] [00] [00] [00]
[404h = 80, 480h = 02]
d000:0000: 00 00 00 00 00 00 00 00
d800:0000: 00 00 00 00 00 00 00 00
e000:0000: 00 00 00 00 00 00 00 00
e800:0000: 00 00 00 00 00 00 00 00
f800:0000: 00 00 00 00 00 00 00 00
[404h = 80, 480h = 03]
d000:0000: 00 00 00 00 00 00 00 00
d800:0000: 00 00 00 00 00 00 00 00
e000:0000: 00 00 00 00 00 00 00 00
e800:0000: 00 00 00 00 00 00 00 00
f800:0000: 00 00 00 00 00 00 00 00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment