views:

55

answers:

2
+2  Q: 

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
+1  A: 

Looks the the string pointer on the stack is a 4(sp), not 6(sp).

augustss
+2  A: 

Discailmer: my knowledge of PDP-11 is a bit rusty, so make sure that this makes sense...

You have 2 problems in your code:

  1. The main part calls prog which calls outp, when it should be simply looping endlessly so that clock will call the printing function. Try putting mainloop: br mainloop in the end of main (just before prog).

  2. The way it's written right now, you're entering outp by branching, but exiting it with rts pc, which is wrong. clock sould call prog using jsr 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.

Tomer Vromen
Is there anyone who's knowledge of PDP-11 **isn't** rusty? If so, I pitty them!
Joachim Sauer