;Example Program ;Traverse a character string in memory to ;force odd parity of each character in the string ; .ORIG x3000 LEA R1, MESS ;R1 locates the string LOOP LDR R0, R1, #0 ;Load the next character BRZ EXIT ; exit if null (0) JSR ODDPAR ;Force odd parity STR R0, R1, #0 ;Overwrite original ADD R1, R1, #1 BRNZP LOOP EXIT TRAP x25 ; MESS .STRINGZ "The boy stood on the burning deck" ;Subroutine to force odd parity of the ASCII character ; in R0 ; ODDPAR ST R7, ODD_7 ;Save working registers ST R4, ODD_4 ST R3, ODD_3 ST R2, ODD_2 ST R1, ODD_1 AND R2, R2, #0 ;Initialize Bit Count ADD R1, R2, #1 ; Test Mask ADD R3, R2, #7 ; Loop Count ODD_L1 AND R4, R0, R1 ;Test next bit BRZ ODD_L2 ADD R2, R2, #1 ;If 1, increment count ODD_L2 ADD R1, R1, R1 ;Prepare next test mask ADD R3, R3, #-1 BRNP ODD_L1 AND R4, R2, #1 BRNP ODD_L3 ADD R0, R0, R1 ODD_L3 LD R1, ODD_1 ;Restore working registers LD R2, ODD_2 LD R3, ODD_3 LD R4, ODD_4 LD R7, ODD_7 RET ; ODD_1 .BLKW 1 ;Register Save Area ODD_2 .BLKW 1 ODD_3 .BLKW 1 ODD_4 .BLKW 1 ODD_7 .BLKW 1 .END