Create a demo program to check if values exist
This commit is contained in:
43
src/chkmat.s
Normal file
43
src/chkmat.s
Normal file
@@ -0,0 +1,43 @@
|
||||
;-*-MIDAS-*-
|
||||
TITLE CHECK MATRIX
|
||||
A=1 ;Define the ACs as universal registers
|
||||
B=2 ;from A to E
|
||||
C=3
|
||||
D=4
|
||||
E=5
|
||||
X=10 ;X and Y are used for indexing
|
||||
Y=11 ;loops etc.
|
||||
P=17 ;Define P as the stack pointer
|
||||
|
||||
PDLLEN==30 ;Set the size of the stack to 30 words.
|
||||
PDL: BLOCK PDLLEN ;Reserve the stack memory
|
||||
|
||||
START: MOVE P,[-PDLLEN,,PDL-1] ;Initializes the stack
|
||||
DONE: .LOGOUT 2, ;Exit from the program
|
||||
|
||||
;Subroutine that checks a byte array, where one byte is a 4-bit value,
|
||||
;for duplicate values.
|
||||
;The algorithm works as follows:
|
||||
;The original word is walked through in for bit steps. Each 4-bit value
|
||||
;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
|
||||
;is already set, the number has already been found the in original set.
|
||||
;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.
|
||||
;The following registers are used:
|
||||
;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.
|
||||
;C: Contains the data field itself: 36 bits, in 4-bit segments.
|
||||
;E: Used as a table to store if a number was found in the field.
|
||||
;X: The byte pointer to the data field.
|
||||
CHKMAT: PUSH P,A ;Save the register A
|
||||
PUSH P,C ;Save the data register
|
||||
PUSH P,E ;Save the E register
|
||||
PUSH P,X ;Save the index register
|
||||
SET E ;Set the hash register to 0.
|
||||
MOVE X,[440400,,C] ;Store a byte pointer to C
|
||||
LOOP: ILDB A,X ;Store a byte in A
|
||||
MOVEI B,E ;Copy the table.
|
||||
LSH B,A ;Shift out the bit to check.
|
||||
ANDI B,1 ;Check if the first bit is set.
|
||||
|
||||
Reference in New Issue
Block a user