Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tks = 177560
- tkb = 177562
- tps = 177564
- tpb = 177566
- .=torg+1000
- Board: .word 0, 2, 0, 2, 0, 2, 0, 2
- .word 2, 0, 2, 0, 2, 0, 2, 0
- .word 0, 2, 0, 2, 0, 2, 0, 2
- .word 0, 0, 0, 0, 0, 0, 0, 0
- .word 0, 0, 0, 0, 0, 0, 0, 0
- .word 1, 0, 1, 0, 1, 0, 1, 0
- .word 0, 1, 0, 1, 0, 1, 0, 1
- .word 1, 0, 1, 0, 1, 0, 1, 0
- main:
- ; inc @#tks ; RE = 1
- ; in: tstb @#tks ; While ( there is no input)
- ; bpl in ; wait for input
- ; movb @#tkb, r1 ; R1 = input character
- mov r1,-(sp);saving environment
- mov r2,-(sp);saving environment
- clr r1;index in board
- clr r2;index in row
- p_row:;loop for printing every single row
- tstb @#tps ; while ( the printer is busy )
- bpl p_row ; wait for printer to be ready
- cmp Board(r1),#1
- beq print_w
- cmp Board(r1),#2
- beq print_b
- cmp Board(r1),#0
- beq print_empt
- print_w:
- mov wite_wrd,@#tpb ; print white
- jmp next_cell
- print_b:
- mov blk_wrd,@#tpb ; print black
- jmp next_cell
- print_empt:
- mov emp_wrd,@#tpb ; print empty cell
- jmp next_cell
- next_cell:
- inc r2;next cell in row
- add #2,r1;
- cmp r1,#200;end of board
- beq finish
- cmp r2,#10;last cell in row
- beq nxt_row;
- jmp p_row
- nxt_row:
- tstb @#tps ; while ( the printer is busy )
- bpl nxt_row ; wait for printer to be ready
- movb strt_lin,@#tpb;
- prp_out2:
- tstb @#tps ; while ( the printer is busy )
- bpl prp_out2 ; wait for printer to be ready
- movb new_line,@#tpb ; print new line
- clr r2;
- jmp p_row
- finish:
- mov(sp)+,r2;saving environment
- mov(sp)+,r1;saving environment
- halt
- ;out: tstb @#tps ; while ( the printer is busy )
- ;bpl out ; wait for printer to be ready
- ;movb Board(r1),@#tpb ; print R1
- ;bic mask1, r1 ; Clear irrelevant bits (high byte)
- ; cmpb r1, end ; if ( r1 == ‘\r’ )
- ; bne main ; go to sof
- ; sof:
- ; tstb @#tps ; while ( the printer is busy )
- ; bpl sof ; wait for printer to be ready
- ;
- ; mov new_line, @#tpb
- ; jmp main
- ; halt
- ;halt ; Stop the program
- strt_lin: .ascii<\r>
- .even
- new_line: .ascii <\n>
- .even
- wite_wrd: .ascii <W>
- .even
- blk_wrd: .ascii<B>
- .even
- emp_wrd: .ascii<_>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement