q usech ; and convert ] to ) cmpb r3 ,#'[ ; and so on bne 70$ movb #'( ,r3 ; convert it. fall thru to next 70$: cmpb r3 ,#'] bne usech movb #') ,r3 br usech skipch: br 120$ ; do not want the char, skip it. .sbttl got a good ch, check for quoted string things usech: bit #c.quot ,pat(r4) ; what about leaving quoted beq 110$ ; strings alone ? tstb inquo(r4) ; currently in a quoted string? bne 90$ ; yes, check for the stopper. cmpb r3 ,#'' ; a quote here ? beq 80$ ; yes cmpb r3 ,#'" ; alternate for a quote bne 90$ ; no 80$: movb r3 ,inquo(r4) ; yes, save the terminator br 110$ ; next please 90$: cmpb r3 ,inquo(r4) ; yes, is this the end of a bne 110$ ; quoted string ? clrb inquo(r4) ; yes, turn the flag off then. 110$: bit #c.prt ,pat(r4) ; should we skip nonprintable beq 115$ ; characters now ? cmpb r3 ,#40 ; yes, less than a space blo 120$ ; yes tstb r3 ; greater than 177 (rubout) bmi 120$ ; yes 115$: movb r3 ,(r2)+ ; if all ok, return the char. 120$: movb r3 ,lastch(r4) ; please save the last ch dec r1 ; and go back for some more. bgt 10$ ; next please 130$: mov r2 ,r0 ; current pointer sub saddr(r4),r0 ; return the length of what's ble 160$ ; nothing left to do then. bit #c.tspa ,pat(r4) ; remove trailing blanks ? beq 160$ ; no mov saddr(r4),r1 ; address of the string. add r0 ,r1 ; point to end of string+1. 140$: cmpb -(r1) ,#40 ; Try for a space first. beq 150$ cmpb (r1) ,#9. ; Not a space, try a tab. bne 160$ 150$: sob r0 ,140$ ; Tab or space. Check next 160$: 170$: add #lsize ,sp ; pop small work area unsave ; pop all temps return ; and exit .save .psect $Pdata,d junkch: .byte 13.,10.,12.,27.,0,0 .restore .dsabl lsb .sbttl l$len get length of .asciz string ; L $ L E N ; ; input: r0 = address of .asciz string ; output: r0 = length of it l$len:: mov r0 ,-(sp) ; save it for later. 10$: tstb (r0)+ ; look for a null character. bne 10$ ; keep going sub (sp)+ ,r0 ; subtract start address from dec r0 ; current pointer less 1. return .sbttl write decimal l$wrdec:: dfwidth = 6 ; ; write a decimal number to KB: passed at 0(r5) ; ; save mov 2(r5) ,r1 ; field width bgt 10$ ; good positive value. beq 5$ ; zero, make it 6. neg r1 ; negative means no space fill br 10$ ; and skip this 5$: mov #dfwidth,r1 ; finally, we have the width. 10$: mov r1 ,r4 ; save for a moment add #5 ,r1 ; make it round up to even num. bic #1 ,r1 ; at last.... mov 2(r5) ,-(sp) ; The real field width please. mov @r5 ,-(sp) ; And the number to print out. mov sp ,r5 ; setup the parameter list addr tst -(r5) ; make room for the buffer on sub r1 ,sp ; the stack. mov sp ,@r5 ; insert the buffer address call l$cvtnum ; and convert the number. .print @r5 ,r4 ; and print it out add r1 ,sp ; and fix the stack up. cmp (sp)+ ,(sp)+ ; rest of stack pop. unsave ; thats all for now return ; write out a decimal number at 2(r5) into the buffer ; address passed at 0(r5). All registers saved. l$cvti::save ; call common conversion sub. clr -(sp) ; setup paramter list first. mov 2(r5) ,-(sp) ; calls $cvtnum,<@r5,2(r5),#0> mov @r5 ,-(sp) ; finally the buffer address. mov sp ,r5 ; the parameter list address. call l$cvtnum ; convert it please. add #6 ,sp ; pop stack parameter list. unsave ; restore r5 return ; and exit please. .sbttl the real conversion sub ; input: 0(r5) = buffer address ; 2(r5) = value to print ; 4(r5) = field width ( > 0 ->right, < 0 -> left ) ; ; field width: if < zero, string will be left justified ; if > zero, string will be right justified ; if = zero, field will be set to 6. ; l$cvtnum:: save ; some scratch registers saved mov (r5) ,r2 ; the buffer address to use. mov 4(r5) ,r3 ; the field width to use. bgt 80$ ; nonzero, it is ok (?) K11SUBMAC[.050032]K11SUB.MAC[.050032]    X14|H [4;Ik(&'( k ߫H&P` \RrPP2PPzPP{PPPPP2P~\$\\TD 0D \~ hi) +\ ^( n ^( np\^txY\^ˀ\!kVk<\F˰<˴ˬ\VVkˤ1`@lP ABCDEFGHIJKLMNOPQRSTUVWXYZ$.?0123456789<@<SЬTЬ UQS>?\\\\\\\\\`:#@'="\abcdefghi\\\\\\\jklmnopqr\\\\\\\~stuvwxyz\\\\\\\\\\\\\\\\\\\\\\{ABCDEFGHI\\\\\\}JKLMNOPQR\\\\\\\\STUVWXYZ\\\\\\0123456789\\\\\  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~@ggh<i|o<m<4p<p<k|Zn<l fr rwx<x<x<x޺<w@]@@fjnr]Ze@@|> | |v<H|  |  |xz|  |zt f r   < &^ @&@'*/V,"?Lh:hmBmz|z{x`y~|fN|@@|@͂|@ ݃ƃ<ns<|Ŏ |️|ep|u|-@率|<ᄇ2ֻr||ZRM | ntB|xyvZw|J=|R>|J? nnaa|bddf0ch[ rval div 3100B ]; rval := rval mod 3100B ; ; aout[2] := r50ch[ rval div 50B ] ; aout[3] := r50ch[ rval mod 50B ] ; end ; rdtoa:: radasc: save ; same some registers mov 2(r5) ,r1 ; go get the rad50 character. mov (r5) ,r3 ; where to put the characters. com: clr r0 ; prepare for divide div #3100 ,r0 ; get first char movb radchr(r0),(r3)+ ; put in buffer clr r0 ; another divide div #50 ,r0 ; this one gives char 2 movb radchr(r0),(r3)+ ; put this in buffer movb radchr(r1),(r3)+ ; and also char 3 unsave ; restore the registers we used. return ; bye .save .psect $Pdata,d .nlist bex radchr: .ascii / ABCDEFGHIJKLMNOPQRSTUVWXYZ$.?0123456789:/ .list bex .even .restore .sbttl get decimal number value ; L $ V A L (20-Nov-80) ; ; (r5) = address of .asciz string to convert ; ; r0 = error (-1 for bad number) ; r1 == binary value of the string. l$val:: save clr r1 ; initailize the result. mov (r5) ,r3 ; the address of the string. clr -(sp) ; a positive number for now. clr r0 30$: tstb @r3 ; null. If so, exit please. beq 5$ ; buy. cmpb @r3 ,#space ; we will ignore spaces. beq 50$ ; if equal, then skip. tst r0 ; past the first space yet ? bne 40$ ; yes, skip sign checks. com r0 ; past all the leading spaces. cmpb @r3 ,#'+ ; positive number ? beq 50$ ; yes, skip over the character. cmpb @r3 ,#'- ; negative ? bne 40$ ; no, try for a digit then. mov sp ,(sp) ; neg, set a useful flag up. br 50$ ; and skip it. 40$: cmpb @r3 ,#'0 ; try comparing to '0' . blo 70$ ; not a digit. time to go cmpb @r3 ,#'9 ; try comparing to '9' . bhi 70$ ; not a digit . get out. clr -(sp) ; clr out the scratch reg. bisb @r3 ,(sp) ; copy the character over. sub #48. ,(sp) ; convert char to a digit. mul #10. ,r1 ; multiply accum by 10 first bcs 60$ ; oops add (sp)+ ,r1 ; add on the digit to accum bvs 70$ ; bye 50$: inc r3 ; pointer := succ( pointer ); br 30$ 60$: tst (sp)+ ; came here from multiply overf 70$: clr r0 ; return 0 in case of error. mov #-1 ,r0 ; ?Illegal number tst (sp)+ ; pop sign flag from stack. br 100$ 5$: tst (sp)+ ; pop sign flag on tos. beq 95$ ; positive number ? tst r1 ; negative 0 (-32768) ? bne 90$ ; no bis #100000 ,r1 ; yes, set only the sign bit br 95$ ; and go away. 90$: neg r1 ; no. 95$: clr r0 100$: unsave return ; and time to leave. .sbttl octval return octal vaule in r1, error in r0 octval::save ; save temps please clr r0 ; assume no error clr r1 ; value := 0 mov @r5 ,r2 ; get the buffer address 10$: movb (r2)+ ,r3 ; get the next character please beq 100$ ; all done cmpb r3 ,#'0 ; error if < '0' or > '7' blo 90$ ; oops cmpb r3 ,#'7 ; how about the upper limit bhi 90$ ; oops sub #'0 ,r3 ; get the value asl r1 ; accumulated value times 8 asl r1 ; the long way asl r1 ; r1 = r1 * 8 add r3 ,r1 ; add in the current digit br 10$ ; next 90$: mov #-1 ,r0 ; illegal number 100$: unsave ; pop registers and exit return .sbttl binary to octal conversion .enabl lsb ; ; 17-Nov-80 BDN ; ; convert binary number at 2(r5) to ascii string ; at buffer address 0(r5). ; l$otoa::save ; save the scratch regs. mov (r5) ,r2 mov 2(r5) ,r3 add #6 ,r2 ; do it backwards mov #6 ,r0 ; do it 6 times 10$: mov r3 ,r1 ; get the number bic #177770 ,r1 ; leave low order 3 bits on movb 200$(r1),-(r2) ; move an octal digit ash #-3 ,r3 ; shift three bytes bic #160000 ,r3 ; zap propagated sign bits sob r0 ,10$ ; go convert next digit unsave return .save .psect $Pdata,D 200$: .ascii \01234567\ ; ascii/octal 200$ .even .restore .dsabl lsb ; (r5) = value to write to KB: l$wroc::save sub #10 ,sp mov sp ,r0 ; use stack for a buffer calls l$otoa ,K11SUBMAC[.050032]K11SUB.MAC[.050032]    X14|H [4;Ik(&'( k ߫H&P` \RrPP2PPzPP{PPPPP2P~\$\\TD 0D \~ hi) +\ ^( n ^( np\^txY\^ˀ\!kVk<\F˰<˴ˬ\VVkˤ1`@lP ABCDEFGHIJKLMNOPQRSTUVWXYZ$.?0123456789<@<SЬTЬ UQS>?\\\\\\\\\`:#@'="\abcdefghi\\\\\\\jklmnopqr\\\\\\\~stuvwxyz\\\\\\\\\\\\\\\\\\\\\\{ABCDEFGHI\\\\\\}JKLMNOPQR\\\\\\\\STUVWXYZ\\\\\\0123456789\\\\\  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~@ggh<i|o<m<4p<p<k|Zn<l fr rwx<x<x<x޺<w@]@@fjnr]Ze@@|> | |v<H|  |  |xz|  |zt f r   < &^ @&@'*/V,"?Lh:hmBmz|z{x`y~|fN|@@|@͂|@ ݃ƃ<ns<|Ŏ |️|ep|u|-@率|<ᄇ2ֻr||ZRM | ntB|xyvZw|J=|R>|J? nnaa|bddf print r0 ,#6. add #10 ,sp unsave return .sbttl copyz copyz .asciz string ; C O P Y Z $ ; ; input: 6(sp) max len or zero ; 4(sp) source string address ; 2(sp) destination string address ; ; usage: copyz macro, as in copyz #oldfile,#newfile copyz$::save ; save registers we may use tst 4+6(sp) ; see if a maxlen was passed bne 5$ ; yes mov #77777 ,4+6(sp) ; no, say we can have MAXINT chars 5$: mov 4+4(sp) ,r0 ; source string address mov 4+2(sp) ,r1 ; destination string address 10$: movb (r0)+ ,(r1)+ ; copy a byte beq 20$ ; until a null is found dec 4+6(sp) ; or we have copied MAXLEN number bne 10$ ; of characters over 20$: clrb -(r1) ; insure output .asciz please unsave ; pop temps mov @sp ,6(sp) ; move return address up add #6 ,sp ; fix the stack return ; and exit .sbttl formatted byte dump ; input: 4(sp) size ; 2(sp) address dump$b::save ; save all please mov <4+6>(sp),r1 ; size beq 100$ ; nothing do to today mov <2+6>(sp),r2 ; address to dump 10$: clr r0 ; get the next byte please bisb (r2)+ ,r0 ; get it decout r0 ; and print it sob r1 ,10$ ; next please 100$: .newline ; a cr/lf unsave ; pop all registers we used mov @sp ,4(sp) ; move return address up cmp (sp)+ ,(sp)+ ; pop two words for parameter list return ; and exit .sbttl strcat and strcpy ; input: ; 0(sp) return address ; 2(sp) dst address ; 4(sp) src address ; output: r0 dest address strcpy::save ; save temp registers please mov 2+2(sp) ,r0 ; destination address mov 2+4(sp) ,r1 ; source .asciz address 10$: movb (r1)+ ,(r0)+ ; copy until a null bne 10$ ; not done mov 2+2(sp) ,r0 ; return the dst address unsave ; pop r1 and exit mov (sp) ,4(sp) ; move return address up now cmp (sp)+ ,(sp)+ ; pop junk and exit return strcat::save ; save temp registers please mov 2+2(sp) ,r0 ; destination address mov 2+4(sp) ,r1 ; source .asciz address 5$: tstb (r0)+ ; look for the end of the dst string bne 5$ ; not found yet dec r0 ; found it, fix the pointer 10$: movb (r1)+ ,(r0)+ ; copy until a null bne 10$ ; not done mov 2+2(sp) ,r0 ; return the dst address unsave ; pop r1 and exit mov (sp) ,4(sp) ; move return address up now cmp (sp)+ ,(sp)+ ; pop junk and exit return strcmp::mov 2(sp),r0 ;Pick up 'a' mov 4(sp),r1 ;And 'b' 10$: cmpb (r0)+,(r1) ;Are they the same bne 20$ ;No tstb (r1)+ ;At the end of the string bne 10$ ;No clr r0 ;Equal return br 100$ 20$: blo 30$ ;Br if ab return br 100$ 30$: mov #-1,r0 ;A decryp:: encryp::mov (sp) ,4(sp) cmp (sp)+ ,(sp)+ return .end