File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ sub AlignUp(in: intptr): (out: intptr) is
1818 out := in;
1919end sub;
2020
21+ sub get_char(): (c: uint8) is
22+ @asm "mov ah, 1";
23+ @asm "int 0x21";
24+ @asm "mov [",c,"],al";
25+ end sub;
26+
2127sub print_char(c: uint8) is
2228 if c == 10 then
2329 @asm "mov dl, 13";
Original file line number Diff line number Diff line change 11var LOMEM: [uint8];
22var HIMEM: [uint8];
3-
3+
44# NB: apout ignores brk()
55sub _find_himem() is
66 @asm "mov #0087h, -(sp)"; # ret
@@ -46,27 +46,21 @@ end sub;
4646
4747sub MemSet(buf: [uint8], byte: uint8, len: uint16) is
4848 var bufend := buf + len;
49- loop
50- if buf == bufend then
51- return;
52- end if;
49+ while buf != bufend loop
5350 [buf] := byte;
54- buf := buf + 1 ;
51+ buf := @next buf ;
5552 end loop;
5653end sub;
5754
5855sub print_oct_i16(value: uint16) is
59- var i: uint8 := 5;
56+ var i: uint8 := 5;
6057 print_char(((value >> 15) + '0') as uint8);
61- loop
62- var digit := (((value >> 12) & 7) + '0') as uint8;
63- print_char(digit);
64- value := value << 3;
65- i := i - 1;
66- if i == 0 then
67- break;
68- end if;
69- end loop;
58+ value := value << 1;
59+ while i > 0 loop
60+ print_char(((value >> 13) + '0') as uint8);
61+ value := value << 3;
62+ i := i - 1;
63+ end loop;
7064end sub;
7165
7266include "common.coh";
Original file line number Diff line number Diff line change @@ -139,10 +139,15 @@ sub FCBClose(fcb: [FCB]): (errno: uint8) is
139139 FCBFlush(fcb);
140140
141141 var fd := fcb.fd;
142+ errno := 0;
142143 @asm "mov ", fd, ", r0";
143144 @asm "trap 6";
144- @asm "neg r0";
145- @asm "mov r0, ", errno;
145+ @asm "adcb ", errno;
146+ @asm "mov r0, ", fd;
147+
148+ if errno != 0 then
149+ errno := fd as uint8;
150+ end if;
146151end sub;
147152
148153sub FCBExt(fcb: [FCB]): (len: uint32) is
You can’t perform that action at this time.
0 commit comments