~grimmware/lc3

bdc92f33fb4d839ff8143a8db397ca7b4223c1cc — glenda 1 year, 9 months ago 16ebec4
Fixed up a bug in the ADD bitmask for literals

Added clearer output for the comparison register debug output
1 files changed, 4 insertions(+), 3 deletions(-)

M lc3.c
M lc3.c => lc3.c +4 -3
@@ 31,7 31,7 @@ op_add(u16int in)
	u16int dr = (in >> 9) & 0x7;
	u16int sr1 = (in >> 6) & 0x7;
	if(in & 1 << 5) { // immediate
		u16int imm5 = signextend(in & 0x17, 5);
		u16int imm5 = signextend(in & 0x1f, 5);
		reg[dr] = reg[sr1] + imm5;
	} else {
		u16int sr2 = in & 0x7;


@@ 46,7 46,7 @@ op_and(u16int in)
	u16int dr = (in >> 9) & 0x7;
	u16int sr1 = (in >> 6) & 0x7;
	if(in & 1 << 5) { // immediate
		u16int imm5 = signextend(in & 0x17, 5);
		u16int imm5 = signextend(in & 0x1f, 5);
		reg[dr] = reg[sr1] & imm5;
	} else {
		u16int sr2 = in & 0x7;


@@ 303,9 303,10 @@ main(int argc, char* argv[])
		}
		if(debug){
			print("r: ");
			for(int i = 0; i<R_COUNT; i++){
			for(int i = 0; i<R_COUNT - 1; i++){
				print(" %04x", reg[i]);
			}
			print(" n: %d z: %d p: %d", reg[R_COUNT-1] & FL_NEG, reg[R_COUNT-1] & FL_ZRO, reg[R_COUNT-1] & FL_POS);
			print("\nmem : ");
			for(int i = 0x3000; i < 0x300a; i++)
				print("%04x ", memory[i]);