diff --git a/src/other/brt.s b/src/other/brt.s index 1295ede..03ae284 100644 --- a/src/other/brt.s +++ b/src/other/brt.s @@ -231,7 +231,7 @@ flush: 0 initio: 0 lac 017777 i - sad d4 +" sad d4 jmp 2f sad d8 jmp 1f @@ -270,7 +270,8 @@ initio: 0 dzm oflg jmp initio i -.argv: 0 +.argv: .+1 +.=.+10 .fin: 0 .fout: 1 eibufp: 0 diff --git a/src/other/brtb.b b/src/other/brtb.b index d3a616c..8439a52 100644 --- a/src/other/brtb.b +++ b/src/other/brtb.b @@ -1,13 +1,13 @@ /* brtb.b - B run-time library */ char(s, n) { - if (n & 1) return ((s[n/2]/512) & 0777); - return(s[n/2] & 0777); + if (n & 1) return(s[n/2] & 0777); + return ((s[n/2]/512) & 0777); } lchar(s, n, c) { - if (n & 1) s[n/2] = (s[n/2] & 0777) | (c*512); - else s[n/2] = (s[n/2] & 0777000) | c; + if (n & 1) s[n/2] = (s[n/2] & 0777000) | c; + else s[n/2] = (s[n/2] & 0777) | (c*512); } putstr(s) { @@ -20,20 +20,6 @@ putstr(s) { } } -/* -getstr(s) { - auto c, i; - - i = 0; - while ((c = getch()) != '*n' & c != '*e') { - lchar(s,i,c); - i = i+1; - } - lchar(s,i,'*e'); - return(s); -} -*/ - putnum(n) { if (n > 9) { putnum(n / 10); @@ -42,6 +28,14 @@ putnum(n) { putchr(n + '0'); } +octal(n) { + if (n > 7) { + octal(n / 8); + n = n & 7; + } + putchr(n + '0'); +} + printf(fmt,x1,x2,x3,x4,x5,x6,x7,x8,x9) { auto adx, c, i; @@ -62,7 +56,9 @@ loop: *adx = -*adx; } putnum(*adx); - } else if (c=='c') + } else if (c=='o') + octal(*adx); + else if (c=='c') putchr(*adx); else if (c=='s') putstr(*adx); diff --git a/src/other/test.b b/src/other/test.b index d98a735..c0259a8 100644 --- a/src/other/test.b +++ b/src/other/test.b @@ -9,7 +9,12 @@ main { extrn fname, fin; - auto ch; + auto ch,p; + + p = 017777; + printf("mem[0%o] = 0%o*n",p,*p); + printf("mem[0%o] = %d*n",*p,**p); + /* fin = open(fname, 0); */ fin = open("abc ", 0);