combine PTY and CHK instruction,

recode remaining operands
This commit is contained in:
Arthur Lu
2022-08-20 01:23:00 -07:00
parent 218445e20c
commit 8e6962ad4d
7 changed files with 40 additions and 49 deletions

View File

@@ -34,12 +34,9 @@ op_type = {
'NXT': 'S',
'CLB': 'G',
'ADD': 'A',
#'SUB': 'A',
#'ORR': 'A',
'AND': 'A',
'LSH': 'T',
'PTY': 'G',
'CHK': 'A',
'RXR': 'G',
'XOR': 'A',
'DNE': 'N',
'JNZ': 'G',
@@ -53,22 +50,19 @@ op_codes = {
'PUT': 0b0_0000_0000,
'GET': 0b0_0001_0000,
'LDW': 0b0_0010_0000,
'STW': 0b0_0010_1000,
'NXT': 0b0_0011_0000,
'CLB': 0b0_0011_1000,
'ADD': 0b0_0100_0000,
#'SUB': 0b0_0101_0000,
#'ORR': 0b0_0110_0000,
'STW': 0b0_0011_0000,
'NXT': 0b0_0100_0000,
'CLB': 0b0_0101_0000,
'ADD': 0b0_0110_0000,
'AND': 0b0_0111_0000,
'LSH': 0b0_1000_0000,
'PTY': 0b0_1000_1000,
'CHK': 0b0_1001_0000,
'RXR': 0b0_1001_0000,
'XOR': 0b0_1010_0000,
'DNE': 0b0_1011_1111,
'JNZ': 0b0_1110_0000,
'JEZ': 0b0_1110_1000,
'JMP': 0b0_1111_0000,
'JAL': 0b0_1111_1000,
'DNE': 0b0_1011_1111,
'JNZ': 0b0_1100_0000,
'JEZ': 0b0_1101_0000,
'JMP': 0b0_1110_0000,
'JAL': 0b0_1111_0000,
'NOP': 0b0_1000_0000
}

View File

@@ -52,7 +52,8 @@ main_loop: LDW r11 // load the next plaintext byte
JMP r0 // jump to main_loop if there is still space for message characters
lfsr_routine: GET r7 // get previous state
AND r6 // and state with taps to get feedback pattern
PTY r0 // get feedback parity bit
CLB r0
RXR r0 // get feedback parity bit
PUT r1 // store feedback bit to r1 temporarily
GET r7 // get previous state again
LSH #d1 // left shift previous state by 1

View File

@@ -94,7 +94,8 @@ main_loop: LDI lfsr_routine // load address for the lfsr_routine label
JMP r0 // jump to main_loop if there is still space for message characters
lfsr_routine: GET r7 // get previous state
AND r6 // and state with taps to get feedback pattern
PTY r0 // get feedback parity bit
CLB r0
RXR r0 // get feedback parity bit
PUT r1 // store feedback bit to r1 temporarily
GET r7 // get previous state again
LSH #d1 // left shift previous state by 1

View File

@@ -90,7 +90,7 @@ finish_preamble: LDI lfsr_routine
JEZ r2 // jump to finish preamble loop if this plaintext == space(32)
LDI correct_pre
PUT r2 // put correct handler address in r2
CHK r1 // check r1 for errors
RXR r1 // check r1 for errors
JEZ r2
error_pre: LDI #x80
STW r12
@@ -106,7 +106,7 @@ main_loop: LDI lfsr_routine // load address for the lfsr_routine label
PUT r1 // store ciphertext in r1
LDI correct
PUT r2 // load address of correct handler in r2
CHK r1 // check r1(ciphertext) for errors
RXR r1 // check r1(ciphertext) for errors
JEZ r2 // if there are no errors, jump to correct handler, otherwise continue to error handler
error: LDI #x80
STW r12
@@ -135,7 +135,8 @@ finish_post: LDI #d32
JMP r0 // otherwise keep on padding spaces to the end
lfsr_routine: GET r7 // get previous state
AND r6 // and state with taps to get feedback pattern
PTY r0 // get feedback parity bit
CLB r0
RXR r0 // get feedback parity bit
PUT r1 // store feedback bit to r1 temporarily
GET r7 // get previous state again
LSH #d1 // left shift previous state by 1