MIT PDP-10 'Info' file converted to Hypertext 'html' format by Henry Baker

Previous Up Next

Separate Even Characters, Odd Vowels, and Odd Consonants.

The following program accepts a line of input (terminated by carriage return) from the terminal and outputs the even (i.e., every second) letters followed by those odd letters that are not vowels, followed by those odd letters that are vowels.

In the program of example 4, take the code

L2:     MOVEI A,0               ;Store a terminating character (code zero)
        IDPB A,B                ;at the end of the string in BUF.
                                ;Now it is an ASCIZ string.
        MOVEI A,BUF
        PUSHJ P,OUTSTR          ;Call OUTSTR to output ASCIZ string
                                ;starting at address in A.
        MOVEI A,[ASCIZ /
/]
        PUSHJ P,OUTSTR          ;Output a CRLF.
        JRST L
and replace it with
L2:     MOVEI A,0               ;Deposit code zero to terminate string
        IDPB A,B                ;of odd letters (i.e., make it ASCIZ).
        MOVE B,[440700,,BUF]    ;Take pointer for odd letters
        MOVE C,B                ;Put pointer for vowels
L3:     ILDB A,B                ;Get one odd letter.
        JUMPE A,L4              ;Stop scanning when we reach the zero.
        PUSHJ P,ISVOW           ;Is this a vowel?
         JRST L3A               ;No.
        IDPB A,C                ;Yes.  Store for later.
        JRST L3

L3A:    .IOT CHTTYO,A           ;Not a vowel, so output now.
        JRST L3

L4:     IDPB A,C                ;Store code zero to end string of vowels.
        MOVEI A,BUF
        PUSHJ P,OUTSTR          ;Output that string.
        MOVEI A,[ASCIZ /
/]
        PUSHJ P,OUTSTR          ;Output a CRLF.
        JRST L

;Subroutine to skip if the character in A is a vowel.
ISVOW:  CAIE A,"A               ;If character is upper case A
         CAIN A,"a              ;or if it is lower case A,
          JRST POPJ1            ;jump to a skip return.
        CAIE A,"E               ;Same for E, etc.
         CAIN A,"e
          JRST POPJ1
        CAIE A,"I
         CAIN A,"i
          JRST POPJ1
        CAIE A,"O
         CAIN A,"o
          JRST POPJ1
        CAIE A,"U
         CAIN A,"u
          JRST POPJ1
        CAIE A,"Y
         CAIN A,"y
          JRST POPJ1
        POPJ P,                 ;Not a vowel, so return with no skip.

;Standard address of single skip return.
POPJ1:  AOS (P)
        POPJ P,

NOTES: