Last fixes tonight

This commit is contained in:
2025-10-04 00:27:06 +02:00
parent f419f72649
commit d7df8501d6
3 changed files with 29 additions and 28 deletions

View File

@@ -39,20 +39,19 @@ polio.elf: polio-main.o polio.s fat12.o paracomm.o stdlib.o
paracli.elf: LDFLAGS += -T doscom.ld paracli.elf: LDFLAGS += -T doscom.ld
paracli.elf: paracli.s paracomm.o paracli.elf: paracli.s paracomm.o
dos-programs = mushroom.elf hello.elf ftpget.elf dos-programs = mushroom.com hello.com ftpget.com
$(dos-programs): LDFLAGS += -T doscom.ld $(dos-programs:.com=.elf): LDFLAGS += -T doscom.ld
mushroom.elf: mushroom.s mushroom.elf: mushroom.s
hello.elf: hello.o stdlib.o crt0.s hello.elf: hello.o stdlib.o crt0.s
ftpget.elf: ftpget.o stdlib.o crt0.s ftpget.elf: ftpget.o stdlib.o crt0.s
polos.img: fat12boot.bin polmon.com polio.com mushroom.com hello.com polos.img: fat12boot.bin polmon.com polio.com $(dos-programs)
dd if=/dev/zero of=$@ bs=512 count=720 dd if=/dev/zero of=$@ bs=512 count=720
mformat -i $@ -t 40 -h 2 -s 9 mformat -i $@ -t 40 -h 2 -s 9
mcopy -i $@ polio.com ::/ mcopy -i $@ polio.com ::/
mcopy -i $@ polmon.com ::/ mcopy -i $@ polmon.com ::/
mcopy -i $@ mushroom.com ::/ mcopy -i $@ $(dos-programs) ::/
mcopy -i $@ hello.com ::/
dd if=fat12boot.bin of=$@ conv=notrunc dd if=fat12boot.bin of=$@ conv=notrunc
.PHONY: clean .PHONY: clean

View File

@@ -19,15 +19,15 @@ int main(int argc, uint16_t argv[]) {
uint8_t ok = 0x42; uint8_t ok = 0x42;
for (int i = 0; i < size; i += chunksize) { for (int i = 0; i < size; ) {
runcomms(kUntilIdle); runcomms(kUntilIdle);
// delay? // delay?
uint8_t len = read(kLpt1, dest, chunksize); int len = read(kLpt1, dest + i, chunksize);
if (len == 0) { if (len <= 0) {
break; break;
} }
write(kLpt1, &ok, 1); write(kLpt1, &ok, 1);
dest += len; i += len;
} }
} }

View File

@@ -46,13 +46,31 @@ void* memset(void* ptr, int val, size_t len) {
return ptr; return ptr;
} }
int _int80h_2(uint8_t fun, uint16_t arg1, uint16_t arg2) {
register uint16_t a1 asm("dx") = arg1;
register uint16_t a2 asm("cx") = arg2;
register uint8_t ah asm("ah") = fun;
register uint16_t ret asm("ax");
asm volatile("push %3 \n\t"
"push %2 \n\t"
"int $0x80 \n\t"
"pop %%cx \n\t"
"pop %%cx \n\t"
: "=r"(ret)
: "r"(ah), "r"(a1), "r"(a2)
: "bx", "cc", "memory");
return ret;
}
int runcomms(char until_idle) { int runcomms(char until_idle) {
register int ret asm("ax"); register int ret asm("ax");
register char ui asm("al") = until_idle; register char ui asm("al") = until_idle;
asm volatile("mov $0x07, %%ah \n\t" asm volatile("mov $0x07, %%ah \n\t"
"int $0x80 \n\t" "int $0x80 \n\t"
: "=r"(ret) : "=r"(ret)
: "r"(until_idle)); : "r"(until_idle)
: "bx", "cx", "dx", "cc", "memory");
return ret; return ret;
} }
@@ -61,28 +79,12 @@ int read(int fd, void* buf, size_t size) {
if (fd != kLpt1) { if (fd != kLpt1) {
return -1; return -1;
} }
register int ret asm("ax"); return _int80h_2(0x05, (uint16_t)buf, size);
asm volatile("push %2 \n\t"
"push %1 \n\t"
"mov $0x05, %%ah \n\t"
"int $0x80 \n\t"
: "=r"(ret)
: "r"(buf), "r"(size));
return ret;
} }
int write(int fd, void* buf, size_t size) { int write(int fd, void* buf, size_t size) {
if (fd != kLpt1) { if (fd != kLpt1) {
return -1; return -1;
} }
register int ret asm("ax"); return _int80h_2(0x06, (uint16_t)buf, size);
asm volatile("push %2 \n\t"
"push %1 \n\t"
"mov $0x06, %%ah \n\t"
"int $0x80 \n\t"
: "=r"(ret)
: "r"(buf), "r"(size));
return ret;
} }