Код:
; attempt to poll the keyboard without using interrupts
.radix 16
.loc 0
nop ;obligatory!
mtps #E0
mov #scr,r0 ;display RAM
mov r0,@#E800
mov #88C6,@#E802
; clear the display RAM
mov #1E0,r1
cls: clr (r0)+
sob r1,cls
br cont
.loc 100
cont: mov #100,@#E812 ;slow clock
; continuously read and display the keyboard scan code
again: jsr pc,keyb
mov #scr,r0
jsr pc,hex
br again
; read the keyboard scan code to R3
keyb: mov #^XF2,@#E814
clr @#E816
keyb1: tstb @#E814
bpl keyb1
mov @#E816,r3
keyb2: tstb @#E814
bpl keyb2
mov #E2,@#E814
rts pc
; display the byte R3 at the screen address R0
hex: jsr pc,hex1
hex1: mov #4,r4
clr r1
hex2: rolb r3
rol r1
sob r4,hex2
jsr pc,putc
rts pc
; display the character R1 at the screen address R0,
; advance the pointer R0 to the next column
putc:
; R1 <- 6 * R1
asl r1 ;* 2
mov r1,-(sp)
asl r1 ;* 4
add (sp)+,r1 ;* 6
add #chars,r1
mov #6,r2
putc1: movb (r1)+,(r0)
add #1E,r0
sob r2,putc1
sub #B2,r0 ;6 * 1E - 2 = B2
rts pc
; characters, width = 8 pixels, height = 6 pixels
chars: .byte 3C, 46, 4A, 52, 62, 3C ;digit '0'
.byte 18, 28, 8, 8, 8, 3E ;digit '1'
.byte 3C, 42, 2, 3C, 40, 7E ;digit '2'
.byte 3C, 42, C, 2, 42, 3C ;digit '3'
.byte 8, 18, 28, 48, 7E, 8 ;digit '4'
.byte 7E, 40, 7C, 2, 42, 3C ;digit '5'
.byte 3C, 40, 7C, 42, 42, 3C ;digit '6'
.byte 7E, 2, 4, 8, 10, 10 ;digit '7'
.byte 3C, 42, 3C, 42, 42, 3C ;digit '8'
.byte 3C, 42, 42, 3E, 2, 3C ;digit '9'
.byte 3C, 42, 42, 7E, 42, 42 ;'A'
.byte 7C, 42, 7C, 42, 42, 7C ;'B'
.byte 3C, 42, 40, 40, 42, 3C ;'C'
.byte 78, 44, 42, 42, 44, 78 ;'D'
.byte 7E, 40, 7C, 40, 40, 7E ;'E'
.byte 7E, 40, 7C, 40, 40, 40 ;'F'
.loc 200
scr: