printer in pdp-11
I have this snippet of the code. can somebody explain why It doesn't work, I want every 5 seconds print "Syntax Error"
thanks in advance
tks = 177560
tkb = 177562
tps = 177564
tpb = 177566
lcs = 177546
. = torg + 2000
main: mov #main, sp
mov #outp, @#64
mov #200, @#66
mov #clock, @#100
mov #300, @#102
mov #101, @#tks
mov #100, @#tps
mov #100, @#lcs
prog: mov #msg, -(sp)
br outp
clock: inc time_is
cmp time_is, time_out
bne clk_end
clr time_is
jmp prog
clk_end:rti
outp:
mov r1,-(sp)
mov r2,-(sp)
mov 6(sp),r2
str_loop:
movb (r2)+,r1
beq pr_str_end
jsr pc, print_char
开发者_运维技巧 br str_loop
pr_str_end:
mov (sp)+,r2
mov (sp)+,r1
rts pc
print_char:
tstb @#tps
bpl print_char
movb r1, @#tpb
rts pc
. = torg + 3000
msg:.ascii<Syntax Error>
.byte 0
.even
time_out: .word 300
time_is: .word 0
buffer: .blkw 3
Discailmer: my knowledge of PDP-11 is a bit rusty, so make sure that this makes sense...
You have 2 problems in your code:
The
main
part callsprog
which callsoutp
, when it should be simply looping endlessly so thatclock
will call the printing function. Try puttingmainloop: br mainloop
in the end ofmain
(just beforeprog
).The way it's written right now, you're entering
outp
by branching, but exiting it withrts pc
, which is wrong.clock
sould callprog
usingjsr prog
.
Another minor problem is that printing the message might take more than 5 second (who knows?) so you need to protect the clock
method form calling outp
again if it's not done.
Good luck.
Looks the the string pointer on the stack is a 4(sp), not 6(sp).
精彩评论