relocated tests

This commit is contained in:
Tom Everett
2016-03-08 18:08:30 -07:00
parent 106d528ef6
commit e3f30f6628
6 changed files with 11 additions and 1 deletions
-48
View File
@@ -1,48 +0,0 @@
" Routine to print AC in decimal
lac testnum " Print an example number
jms decprnt; -5 " with five digits
sys exit
decprnt: 0
dac num
lac endptr " Point at the end of the buffer
dac dbufptr
dzm count " and set no characters so far
lac num
1: cll
sza " Is there anything left in the number?
jmp 3f
lac o60 " No, so put a space into the buffer
jmp 4f
3: idiv; 10 " Divide AC by 10
tad o60 " Add ASCII '0'
4: dac dbufptr i " and save the character into the buffer
-1 " Move pointer back a word
tad dbufptr
dac dbufptr
isz count " Bump up the count of characters
lacq " and move the quotient into AC
isz decprnt i " Add 1 to the # digits the user wants
jmp 1b " Loop back for the next digit
5: isz dbufptr " Restore the pointer to the first digit
lac d1 " Print as a string on stdout
sys write; dbufptr:dbufend; count:0
isz decprnt
jmp decprnt i " and return from the routine
" We set aside 5 words to buffer the characters, and we write
" from the end backwards to the front
dbuf: .=.+4 " First 4 words in the buffer
dbufend: 0 " and the last word
endptr: dbufend
d1: 1
o40: 040
o60: 060
num: 0
zero: 0>
testnum: 1234
-39
View File
@@ -1,39 +0,0 @@
" Fork text code
main:
sys fork
jmp parent
child:
lac d1
sys write; childmsg; 3
sys smes
sys exit
parent:
dac pid " save the childs pid
lac d1
sys write; parentmsg; 4
sys rmes " wait for the child to exit
sad pid " did we get the same pid back?
jmp ok
wrong:
lac d1
sys write; badpid; 4
sys exit
ok:
lac d1
sys write; goodpid; 4
sys exit
d1: 1 " stdout fd
pid: 0 " child's pid
parentmsg: <pa>; <re>; <nt>; 012000
childmsg: <ch>; <il>; <d 012
goodpid: <go>; <od>; <pi>; <d 012
badpid: <ba>; <dp>; <id>; 012000
-46
View File
@@ -1,46 +0,0 @@
" 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
-11
View File
@@ -1,11 +0,0 @@
lac d10
cll " clear link
mul " mutiply by radix
num2: 10
lacq
cll
idiv; 10
nop
hlt
d10: 10
-61
View File
@@ -1,61 +0,0 @@
" Test program for several system calls: open, read, write, close, exit
" Do:
" ./as7 write_test.s > a.out
" ./a7out -d a.out
main:
" Test the lac, dac instructions
lac in
dac out
" Write hello to fd1 i.e stdout
lac d1
sys write; hello; 7
" Test if the assembler can dac into a mid-line label
lac helloptr
dac 1f
lac d1
sys write; 1:0; 7
" Try to open file fred
sys open; fred; 0;
" read 5 words into the buffer from stdin: type in 10 or more characters!
lac d0
sys read; buf; 5
" Stop and dump memory, so you can see five words at location 0400
" Comment out the hlt instruction to test close and exit
hlt
" close stdin
lac d0
sys close
" exit
sys exit
" We should not get to the halt instruction
hlt
" Some memory locations for lac and dac
. = 0100
in: 023
. = 0200
out: 0
" Hello, world\n, two ASCII chars per word
hello: <He>; <l 0154; 0157 ,>; 040; <wo>; <rl>; <d 012
helloptr: hello
" fred as a four word filename
fred: <fr>; <ed>; 040040; 040040
" Input buffer for read
. = 0400
buf: 0
d0: 0
d1: 1