.TITLE ASCII FORMATTING .IDENT /V1.01/ .NLIST TOC,SYM .ENABL LC ; Part of Sira Paper Tape Punch Despooler. ; ; COPYRIGHT(C) 1981,1982 Sira Institute Ltd., ; South Hill, Chislehurst, Kent, BR7 5EH, England. ; ; Author: C.J. Doran ; ; Assemble as: ; >MAC PPPASCII=PPPASCII ;+ ; Format ASCII output. Do case conversion if needed, then set parity as ; required. ; On entry: %3-> start of buffer, ; %4 is no of bytes, ; %2-> end of buffer. ; Adjust these on exit to describe the new buffer. ; ; MODIFICATIONS RECORD ; ==================== ; V1.01 CJD 12-Jul-82 ; Re-enable case conversion now DEC have it working! Note, unlike ; DEC despoolers, it does actually do an upper-case convert. ; Re-write parity check, smaller and faster, noting that even is the ; most likely requirement. ;- .PSECT CODE,I,RO ASCII:: JSR PC,CARIAG ; Put in carriage-control MOV %3,%1 ; Copy start pointer .IF GE V$$RSN-40 ; Convert buffer to upper case if required. TSTB UCLC ; Punch upper case only? BNE 13$ ; No, leave case as it stands 11$: BICB #^C177,@%1 ; Clear unwanted bits CMPB @%1,#'a ; <'a'? BLO 12$ ; Yes, don't change CMPB @%1,#'z ; or >'z'? BHI 12$ ; Yes, don't change BICB #40,@%1 ; No, clear bit 6, changing LC to UC 12$: INC %1 ; Advance pointer CMP %1,%2 ; Reached end of buffer? BLO 11$ ; No, go for next character MOV %3,%1 ; Reset buffer pointer .ENDC ; Now do parity check. 13$: MOVB @%1,%0 ; Get char CLR -(SP) ; Clear a bit counter CMPB FORM,#F.EVEN ; Even parity required? BEQ 20$ ; Yes, go do parity check with carry clear CMPB FORM,#F.ODD ; No, odd required? SEC ; Will start with a set bit if so BEQ 20$ ; when computing parity ; Not odd or even, must be set or clear. TST (SP)+ ; Don't need bit counter BICB #^C177,%0 ; Clear bit 7 in case CMPB FORM,#F.CLR ; parity clear reqd? BEQ 40$ ; When that's all BR 39$ ; Else must be set ; Compute parity for odd or even. 20$: ADC @SP ; Add last bit to counter RORB %0 ; Shift out another BNE 20$ ; Repeat if not got them all ADC @SP ; Don't forget the last MOVB @%1,%0 ; Get character back ASR (SP)+ ; Get its actual parity BCC 40$ ; Branch if already right 39$: ADD #200,%0 ; Wrong, flip bit 7 40$: MOVB %0,(%1)+ ; and put revised char back JSR PC,UPCSUM ; Update checksum CMP %1,%2 ; Reached end of buffer? BLO 13$ ; No, repeat RTS PC ; Yes, done .END