Fix the move D, command.
This commit is contained in:
28
src/chkmat.s
28
src/chkmat.s
@@ -18,26 +18,40 @@ DONE: .LOGOUT 2, ;Exit from the program
|
|||||||
;Subroutine that checks a byte array, where one byte is a 4-bit value,
|
;Subroutine that checks a byte array, where one byte is a 4-bit value,
|
||||||
;for duplicate values.
|
;for duplicate values.
|
||||||
;The algorithm works as follows:
|
;The algorithm works as follows:
|
||||||
;The original word is walked through in for bit steps. Each 4-bit value
|
;The original word is walked through in 4-bit steps. Each 4-bit value
|
||||||
;is read, and its value is used as a bit pointer to the 'hashing'-register.
|
;is read, and its value is used as a bit pointer to the 'hashing'-register.
|
||||||
;If a number is found, the bit in the hashing register is set. If the bit
|
;If a number is found, the bit in the hashing register is set. If the bit
|
||||||
;is already set, the number has already been found the in original set.
|
;is already set, the number has already been found the in original data.
|
||||||
;To make the walk through easy, we use a special feature of the PDP-10:
|
;To make the walk through easy, we use a special feature of the PDP-10:
|
||||||
;We access the data register, as if it was a memory address.
|
;We access the data register, as if it was a memory address.
|
||||||
;The following registers are used:
|
;The following registers are used:
|
||||||
;A: Accumulator used to store the values that are read from the data field.
|
;A: Accumulator used to store the values that are read from the data field.
|
||||||
;B: Used to check if a bit is set, without destroying the contents of I.
|
;B: Used to check if a bit is set, without destroying the contents of I.
|
||||||
;C: Contains the data field itself: 36 bits, in 4-bit segments.
|
;C: Contains the data field itself: 36 bits, in 4-bit segments.
|
||||||
|
;D: Contains the result, 0 if successfull, else >0.
|
||||||
;E: Used as a table to store if a number was found in the field.
|
;E: Used as a table to store if a number was found in the field.
|
||||||
;X: The byte pointer to the data field.
|
;X: The byte pointer to the data field.
|
||||||
CHKMAT: PUSH P,A ;Save the register A
|
CHKMAT: PUSH P,A ;Save the register A
|
||||||
|
PUSH P,B ;Save the B-register
|
||||||
PUSH P,C ;Save the data register
|
PUSH P,C ;Save the data register
|
||||||
PUSH P,E ;Save the E register
|
PUSH P,E ;Save the E register
|
||||||
PUSH P,X ;Save the index register
|
PUSH P,X ;Save the index register
|
||||||
SET E ;Set the hash register to 0.
|
MOVEI D,11 ;Load D with 16.
|
||||||
|
SETZ E ;Set the hash register to 0.
|
||||||
MOVE X,[440400,,C] ;Store a byte pointer to C
|
MOVE X,[440400,,C] ;Store a byte pointer to C
|
||||||
LOOP: ILDB A,X ;Store a byte in A
|
CKLOOP: SOJE D,CHKEXT ;All bits set?
|
||||||
MOVEI B,E ;Copy the table.
|
ILDB A,X ;Store a byte in A
|
||||||
LSH B,A ;Shift out the bit to check.
|
MOVEI B,1 ;Set B to 1
|
||||||
ANDI B,1 ;Check if the first bit is set.
|
LSH B,A ;Set the Ath bit in the mask
|
||||||
|
TRNE E,B ;Test, if a bit is already set
|
||||||
|
JRST CHKEXT ;Double value found, exit.
|
||||||
|
IORI E,B ;Set the Ath bit in the code
|
||||||
|
JRST LOOP ;Back to the loop
|
||||||
|
CHKEXT: POP P,X ;Restore X
|
||||||
|
POP P,E ;Restore E
|
||||||
|
POP P,C ;Restore C
|
||||||
|
POP P,B ;Restore B
|
||||||
|
POP P,A ;Restore A
|
||||||
|
POPJ P, ;Return from function
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user