;APRIL 11, 1986 ;BY RONALD E. JACOBS ;THIS PROGRAM READS THE MPZ80 SWITCHES 1-6 AND /PINT ;TYPE ANY KEY TO EXIT .z80 jp 1000h org 0EFDh halt halt call curoff ;turn off the cursor call uinit ;select serial port 1 repeat: ld a,(402h) push af call lbyte call conv call cout pop af call conv call cout call spacer call binary call bs ;backspace ten spaces call done ;see if to warm boot because character at kbd jp repeat LBYTE: RRCA RRCA RRCA RRCA ret CONV: AND 00fh ADD A,090H DAA ADC A,040H DAA LD C,A ret base equ 48h group1 equ 1 grpctl equ 4Fh lsr equ base+5 thre equ 20h thr equ base dr equ 1 ;data ready in receiver buffer reg. rbr equ base uinit: ld a,group1 out (grpctl),a ;set up for UART 1 ret done: in a,(lsr) ;get uart status and dr ;character typed at terminal? ret z in a,(rbr) ;clear the buffer by reading it ld c,1bh ;ascii escape sequence to turn cursor back on call cout ld c,'.' ;ascii . call cout ld c,'0' ;ascii 0 call cout ld hl,0000 ;program counter <-- 0000 for task 1 ld (0015h),hl jp 0815h ;restore task 1 (warm boot) cout: in a,(lsr) ;get uart status and thre jr z,cout ;loop until tbe ld a,c out (thr),a ;output the data to uart ret ; ;backspace a number of spaces ; bs: ld b,12d ;count of # of backspaces bs1: ld c,08 ;ascii backspace call cout dec b ;decrement count jp nz,bs1 ret curoff: ld c,1bh ;ascii escape call cout ld c,'.' ;ascii . call cout ld c,'1' ;ascii 1 call cout ret binary: ld a,(402h) ;cpu switch port ld b,8 ;8 bits count nxtbit: rlca ld h,a ;save the a register and 00000001b ;mask all but lowest bit cp 1 ;is the bit a 1 ? ld c,'0' jp nz,putbit ;put a '1' to the terminal ld c,'1' putbit: call cout ;put a '0' to the terminal ld a,h ;retrieve the a register deã â ;alì ¸ digitó done? ret z jp nxtbit ;do next binary digit spacer: call space1 ;print two spaces space1: ld c,' ' ;prepare to print a space call cout ret end