ch14p1.s
Original bytes preserved. This is a browser-readable view.
; MD-120 diagnostic command 0x31 on the FX-870P org 0 start 0 ld $0,&H05 ;FDD command &H05: enter the diagnostic mode cal cm1 ;send the command $0 to the FDD ld $0,&H31 ;diagnostic command &H31: write to the LED cal cm1 ;send the command $0 to the FDD ld $0,&H4E ;pattern 'C' cal wr1 ;write byte $0 to the FDD cal delay ld $0,&H77 ;pattern 'A' cal wr1 ;write byte $0 to the FDD cal delay ld $0,&H5B ;pattern 'S' cal wr1 ;write byte $0 to the FDD cal delay ld $0,&H30 ;pattern 'I' cal wr1 ;write byte $0 to the FDD cal delay ld $0,&H7E ;pattern 'O' cal wr1 ;write byte $0 to the FDD cal delay ld $0,$sx ;terminate the command cal wr1 ;write byte $0 to the FDD cal delay cal rd1 ;read a byte from the FDD to $0 ld $0,&H21 ;diagnostic command &H21: system restart cal cm1 ;send the command $0 to the FDD pst ua,&H54 rtn ; delay 500 ms delay: ldw $0,19762 delay1: sbw $0,$sy ;14 cycles jr nz,delay1 ;9 cycles rtn ; read a byte from the FDD to $0 rd1: gst ua,$1 ld $2,$1 or $2,&H30 pst ua,$2 pre ix,&HFFFF rd2: ld $0,(ix+$sx) ;FDD status anc $0,$sy jr nz,rd2 ;wait until the FDD sends the data byte ld $0,(ix-$sy) ;FDD data pst ua,$1 rtn ; write a byte $0 to the FDD wr1: gst ua,$1 ld $2,$1 or $2,&H30 pst ua,$2 pre ix,&HFFFF st $0,(ix-$sy) ;FDD data wr2: ld $0,(ix+$sx) ;FDD status anc $0,&H02 jr z,wr2 ;wait until the FDD reads the data byte pst ua,$1 rtn ; write a command $0 to the FDD cm1: gst ua,$1 ld $2,$1 or $2,&H30 pst ua,$2 pre ix,&HFFFF st $0,(ix+$sx) ;FDD command cm2: ld $0,(ix+$sx) ;FDD status anc $0,&H04 jr z,cm2 ;wait until the FDD reads the command byte pst ua,$1 rtn