commit aa10ea0fbd7e99568897e47d0396839b45e8b18c from: Sven M. Hallberg date: Sun Oct 09 14:09:46 2022 UTC test writing to A in a jump instruction An instruction such as A=0;JMP should branch to the address active at the start of the clock cycle rather than the new value of A which does not update until the next cycle. commit - 5c25183eee499db2e6d43608b70a853650e91381 commit + aa10ea0fbd7e99568897e47d0396839b45e8b18c blob - 64351d9b25df70f863b5384491982b952458d081 blob + 26042cc3083a517e72af98385884ed1343d7b766 --- Makefile +++ Makefile @@ -1,7 +1,7 @@ CFLAGS += -Wall PROGS = hackem rom -ROMS = add.rom max.rom term0.rom term1.rom term2.rom hello.rom atoi.rom +ROMS = add.rom max.rom term0.rom term1.rom term2.rom dest.rom hello.rom atoi.rom .PHONY: all test clean all: ${PROGS} ${ROMS} blob - /dev/null blob + ff6041636ec5612f960b702afa2604868bbbfca4 (mode 644) --- /dev/null +++ dest.hack @@ -0,0 +1,10 @@ + # writing to A in a jump does not affect the destination +0 000000000000110 # 0: @Y +1 11 0 110000 010 000 # 1: D=A; +0 000000000000101 # 2: @X +1 11 0 001100 100 111 # 3: A=D;JMP // should go to X (5) with A=D=Y (6) +1 11 0 101010 100 000 # 4: A=0; // not reached (infinite loop) + # 5: (X) +1 11 0 101010 010 000 # D=0; + # 6: (Y) // only reached with A=6 D=0 +1 11 0 101010 000 111 # 0;JMP // terminates blob - /dev/null blob + c69443edc234b5d184d216c0d37e01f80363627b (mode 644) --- /dev/null +++ dest.tsv @@ -0,0 +1,7 @@ +T PC instr. A D R0/SP R1/LCL R2/ARG R3/THIS R4/THAT +0 0 000006 0 0 0 0 0 0 0 +1 1 166020 6 0 0 0 0 0 0 +2 2 000005 6 6 0 0 0 0 0 +3 3 161447 5 6 0 0 0 0 0 +4 5 165220 6 6 0 0 0 0 0 +5 6 165207 6 0 0 0 0 0 0