Your place is saved automatically on this browser.
Before running experimental machine code
Assembly success tells us that the source is syntactically valid; it does not prove that the program is logically safe. A perfectly valid machine-code program can still jump to the wrong place, overwrite memory or fail to return.
For early experiments, keep the program tiny, save the source first, and run only code whose instructions we have just discussed. If an experiment ever leaves the machine unresponsive, a reset or reboot may be necessary; saved source can then be loaded again.
Run with R
Enter:
On Odin Dev.2k, R executes the assembled program and then shows an inspection screen containing CPU registers, flags and memory rows.
What we deliberately changed
Our program deliberately loaded A with $42 and HL with $6000. Odin therefore showed values consistent with:
AF = 42A0
HL = 6000AF is displayed as a 16-bit pair. The first byte is A, so 42 tells us that our LD A,$42 instruction worked. The second byte is F. At this point we had not deliberately recalculated the flags, so $A0 was inherited state rather than a result we intended to study.
What PC was doing while this tiny program ran
Using the bytes we already inspected, we can sketch the instruction flow. This is a conceptual view; Odin and the CPU handle the details automatically.
$6000: 3E 42 LD A,$42 ; 2 bytes
$6002: 21 00 60 LD HL,$6000 ; 3 bytes
$6005: C9 RET ; 1 byteThe CPU begins at the first instruction, consumes the bytes belonging to it, and moves to the next instruction address. RET then changes the normal sequence by restoring the saved return address.
Why the HL memory row was so useful
Because HL contained $6000, Odin's HL-based memory row pointed directly at our own program. It showed:
3E 42 21 00 60 C9This connects three different views of the same program: the source we typed, the address Odin assigned, and the machine-code bytes stored in memory.
Expected results for the first successful program
If you entered the same source on Odin Dev.2k, these are useful comparison points. Unrelated register values may differ because our code does not deliberately set them.
If an important result differs, stop and compare the source line by line rather than pressing on.
