assembly of pdp-11(simulator)

Posted by lego69 on Stack Overflow See other posts from Stack Overflow or by lego69
Published on 2010-06-13T17:07:53Z Indexed on 2010/06/13 17:12 UTC
Read the original article Hit count: 255

Filed under:
|
|

I have this code on pdp-11

tks = 177560
tkb = 177562
tps = 177564
tpb = 177566
lcs = 177546
. = torg + 2000

main:   mov #main, sp
        mov #kb_int, @#60
        mov #200, @#62
        mov #101, @#tks
        mov #clock, @#100
        mov #300, @#102
        mov #100, @#lcs

loop:   mov @#tks,r2
        aslb r2
        bmi loop
        halt

clock:  tst bufferg
        beq clk_end
        mov #msg,-(sp)
        jsr pc, print_str
        tst (sp)+
        clr bufferg
        bic #100,@#tks
        clr @#lcs
clk_end:rti

kb_int: mov r1,-(sp)
        jsr pc, read_char
        movb r1,@buff_ptr
        inc buff_ptr
        bis #1,@#tks
        cmpb r1,#'q
        bne next_if
        mov #0, @#tks
next_if:cmpb r1,#32.
        bne end_kb_int
        clrb @buff_ptr
        mov #buffer,-(sp)
        jsr pc, print_str 
        tst (sp)+
        mov #buffer,buff_ptr
end_kb_int:
        mov (sp)+,r1
rti


;#############################
read_char:
        tstb @#tks
        bpl read_char
        movb @#tkb, r1
        rts pc
;#############################
print_char:
        tstb @#tps
        bpl print_char
        movb r1, @#tpb
        rts pc
;#############################
print_str:
        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

. = torg + 3000
msg:.ascii<Something is wrong!>
    .byte 0
    .even
buff_ptr: .word buffer
buffer: .blkw 3
bufferg: .word 0

Can somebody please explain how this part is working, thanks in advance

movb r1,@buff_ptr
            inc buff_ptr
            bis #1,@#tks
            cmpb r1,#'q
            bne next_if
            mov #0, @#tks
    next_if:cmpb r1,#32.
            bne end_kb_int
            clrb @buff_ptr
            mov #buffer,-(sp)
            jsr pc, print_str 
            tst (sp)+
            mov #buffer,buff_ptr

© Stack Overflow or respective owner

Related posts about assembly

Related posts about programming