fix bug in PC jump target calculation,
fix bug in RegFile input width, fix control logic bug with INC/DEC, change assembler output format, change programs to use d0 as space char value
This commit is contained in:
@@ -99,7 +99,8 @@ def get_immediate(operand, labels):
|
||||
|
||||
output = sys.argv[1]
|
||||
targets = sys.argv[2:]
|
||||
out = open(output, "wb")
|
||||
#out = open(output, "wb")
|
||||
out = open(output, "w")
|
||||
print('detected targets: ' + str(targets))
|
||||
for file in targets:
|
||||
print('assembing: ' + file)
|
||||
@@ -139,4 +140,5 @@ for file in targets:
|
||||
for inst in tqdm(instructions, desc='Assembly', unit=' instructions'):
|
||||
opcode = op_codes[inst[0]]
|
||||
operand = inst[1]
|
||||
out.write((opcode| operand).to_bytes(length=2, byteorder='big'))
|
||||
out.write(format(opcode | operand, 'b') + '\n')
|
||||
#out.write((opcode| operand).to_bytes(length=2, byteorder='big'))
|
@@ -1,2 +1,2 @@
|
||||
#!/bin/sh
|
||||
python assembler.py cse141L.bin program1.asm program2.asm program3.asm
|
||||
python assembler.py machine_code.txt program1.asm program2.asm program3.asm
|
@@ -24,7 +24,7 @@ init: LDI #d62
|
||||
PUT r8 // init r8 decrementer with number of preamble space chars
|
||||
LDI #d64
|
||||
PUT r9 // init r9 decrementer to total number of possible ciphertext chars
|
||||
preamble_loop: LDI #d32 // get space character decimal 32
|
||||
preamble_loop: LDI #d0 // get space character decimal 0
|
||||
XOR r7 // bitwise XOR the current state with plaintext space to generate ciphertext
|
||||
CLB r0 // clear the leading bit of the ciphertext as in requirements
|
||||
STW r12 // store ciphertext to write pointer
|
||||
|
@@ -59,7 +59,7 @@ tap_init: LDI #d64
|
||||
NXT r9 // decrement total encryption chars remaining
|
||||
tap_loop: LDI lfsr_routine
|
||||
JAL r0 // jump to lfsr routine which calculates next state in r7
|
||||
LDI #d32 // load space char expected plaintext
|
||||
LDI #d0 // load space char expected plaintext
|
||||
XOR r7
|
||||
CLB r0 // clear leading bit in the expected ciphertext
|
||||
PUT r1 // store expected cipher text in r1
|
||||
|
@@ -59,7 +59,7 @@ tap_init: LDI #d64
|
||||
NXT r9 // decrement total encryption chars remaining
|
||||
tap_loop: LDI lfsr_routine
|
||||
JAL r0 // jump to lfsr routine which calculates next state in r7
|
||||
LDI #d32 // load space char expected plaintext
|
||||
LDI #d0 // load space char expected plaintext
|
||||
XOR r7
|
||||
CLB r0 // clear leading bit in the expected ciphertext
|
||||
PUT r1 // store expected cipher text in r1
|
||||
|
Reference in New Issue
Block a user