I wrote a test for the octal conversion routine, and I updated ds.s

with the comments that I wrote for the octal conversion.
This commit is contained in:
Warren Toomey
2016-03-04 14:34:25 +10:00
parent 5b9ecc343d
commit 575163a35a
2 changed files with 67 additions and 19 deletions
+21 -19
View File
@@ -363,28 +363,30 @@ putname: 0
jmp putname i jmp putname i
octal: 0 octal: 0
lmq lmq " Move the negative argument into the MQ
lac d5 " as we will use shifting to deal with the
tad octal i " number by shifting groups of 3 digits.
cma lac d5 " By adding 5 to the negative count and
dac c tad octal i " complementing it, we set the actual
cma " loop count up to 6 - count. So, if we
dac c " want to print 2 digits, we lose 6 - 2 = 4 digits
1: 1:
llss 3 llss 3 " Lose top 3 bits of the MQ
isz c isz c " Do we have any more to lose?
jmp 1b jmp 1b " Yes, keep looping
lac octal i lac octal i " Save the actual number of print digits into c
dac c dac c " as a negative number.
1: 1:
" ecla llss 3 cla
llss 3 llss 3 " Shift 3 more bits into AC
tad o60 tad o60 " Add AC to ASCII '0'
jms putc " and print out the digit
isz c " Any more characters to print out?
jmp 1b " Yes, loop back
law 040 " Print out a space
jms putc jms putc
isz c isz octal " Move return address 1 past the argument
jmp 1b jmp octal i " and return from subroutine
law 040
jms putc
isz octal
jmp octal i
error: 0 error: 0
-1 -1
+46
View File
@@ -0,0 +1,46 @@
" Octal test: This code borrowed from ds.s to test the llss
" instruction. It should print out num in octal followed by
" a space.
lac num
jms octal; -3
sys exit
octal: 0
lmq " Move the negative argument into the MQ
" as we will use shifting to deal with the
" number by shifting groups of 3 digits.
lac d5 " By adding 5 to the negative count and
tad octal i " complementing it, we set the actual
cma " loop count up to 6 - count. So, if we
dac c " want to print 2 digits, we lose 6 - 2 = 4 digits
1:
llss 3 " Lose top 3 bits of the MQ
isz c " Do we have any more to lose?
jmp 1b " Yes, keep looping
lac octal i " Save the actual number of print digits into c
dac c " as a negative number.
1:
cla
llss 3 " Shift 3 more bits into AC
tad o60 " Add AC to ASCII '0'
dac buf " and print out the digit
lac fd1
sys write; buf; 1
isz c " Any more characters to print out?
jmp 1b " Yes, loop back
lac o40 " Print out a space
dac buf
lac fd1
sys write; buf; 1
isz octal " Move return address 1 past the argument
jmp octal i " and return from subroutine
fd1: 1
d5: 5
o40: 040
o60: 060
num: 0126
buf: 0
c: .=.+1