remove more comments from assembler,

added multiprogram assembly functionality,
added proper next program logic to programs
This commit is contained in:
Arthur Lu 2022-08-10 06:01:47 +00:00
parent 1a44a5be80
commit 78b38b573d
4 changed files with 16 additions and 8 deletions

View File

@ -62,7 +62,8 @@ op_codes = {
'JNZ': 0b0_1110_0000,
'JEZ': 0b0_1110_1000,
'JMP': 0b0_1111_0000,
'JAL': 0b0_1111_1000
'JAL': 0b0_1111_1000,
'NOP': 0b0_1000_0000
}
def get_reg(type, opcode):
@ -94,6 +95,7 @@ def get_immediate(operand, labels):
output = sys.argv[1]
targets = sys.argv[2:]
out = open(output, "wb")
print('detected targets: ' + str(targets))
for file in targets:
print('assembing: ' + file)
@ -127,9 +129,9 @@ for file in targets:
else:
operand = get_reg(op_type[opcode], operand)
instructions.append((opcode, operand))
#print(str(index+1) + " " + str(opcode) + " " + str(operand))
index += 1
out = open(output, "wb")
for i in tqdm(range(len(instructions), 256), desc='Paging', unit='instructions'):
instructions.append(("NOP", 0b0_0000_0000)) # append many NOPs to fill up the 256 instruction program block
for inst in tqdm(instructions, desc='Assembly', unit=' instructions'):
opcode = op_codes[inst[0]]
operand = inst[1]

View File

@ -62,3 +62,5 @@ lfsr_routine: GET r7 // get previous state
JMP r0 // return to function call address
done: LDI #b10000000 // load the processor flag state needed to halt the program
PUT r15 // put and set the done flag to 1 to halt the PC and indicate the program has finished
LDI #d255
JMP r0

View File

@ -103,3 +103,5 @@ lfsr_routine: GET r7 // get previous state
JMP r0 // return to function call address
done: LDI #b10000000 // load the processor flag state needed to halt the program
PUT r15 // put and set the done flag to 1 to halt the PC and indicate the program has finished
LDI #d255
JMP r0

View File

@ -111,3 +111,5 @@ lfsr_routine: GET r7 // get previous state
JMP r0 // return to function call address
done: LDI #b10000000 // load the processor flag state needed to halt the program
PUT r15 // put and set the done flag to 1 to halt the PC and indicate the program has finished
LDI #d255
JMP r0