BLUE
kissa.bsky.social
@kissa.bsky.social
Tomfoolery, nincompoopery, programming
37 followers374 following39 posts
kissa.bsky.social

Day 2 of virtual machine hacking, think I’ll do byte addressing now

Autumn
1

kissa.bsky.social

Added some printf debugging machinery to find out why my second add instruction didn't run, can you guess why?

✓ jump relative with add [0.03ms]
step: pc 0x0100
step: instr add (0x0000)
step: pc 0x0104
step: instr hlt (0x00f0)
✓ program with byte addressing [0.08ms]
test("program with byte addressing", () => {
	// add a, a, c.hi
	write8(0x100, instructions.add)
	write8(0x101, A)
	write8(0x102, A)
	write8(0x103, hi(C))
	// add b, c, c.lo
	write8(0x104, instructions.add)
	write8(0x105, B)
	write8(0x106, B)
	write8(0x107, lo(C))
	write8(0x104, instructions.hlt)

	// Set initial values to registers and point PC to start
	write(PC, 0x100)
	// C contains high byte 0x1f, and low byte 0xf1
	write(C, 0x1ff1)

	debugOn()
	run()
	debugOff()

	// expect(read(A)).toBe(0x1f)
	// B should be sign-extended
	// expect(read(B)).toBe(0xfff1)
})
1
kissa.bsky.social
@kissa.bsky.social
Tomfoolery, nincompoopery, programming
37 followers374 following39 posts