Your place is saved automatically on this browser.
Do these slowly. The purpose is to become comfortable with the notation, not to race through them.
- Convert decimal 10, 15, 16, 42, 64, 127, 128 and 255 to hexadecimal.
- Convert $0A, $0F, $10, $2A, $40, $7F, $80 and $FF to decimal.
- Write the binary form of $00, $01, $0F, $10, $42 and $FF.
- For the 16-bit value $1234, identify the high byte and the low byte.
- Explain in your own words why one hexadecimal digit maps neatly to one nibble.
- Explain why an 8-bit register cannot contain the unsigned value 256.
- Explain the difference between an address such as $6000 and a byte stored at that address.
- Explain the difference between A and F in the AF display.
- Explain why LD A,$42 did not give us meaningful new arithmetic flags, but ADD A,$01 did.
Exercise answers
Try the exercises before reading these answers. The aim is not to score yourself; it is to identify anything that deserves another example.
Decimal to hexadecimal
10 = $0A
15 = $0F
16 = $10
42 = $2A
64 = $40
127 = $7F
128 = $80
255 = $FFHexadecimal to decimal
$0A = 10
$0F = 15
$10 = 16
$2A = 42
$40 = 64
$7F = 127
$80 = 128
$FF = 255Binary forms
$00 = 00000000
$01 = 00000001
$0F = 00001111
$10 = 00010000
$42 = 01000010
$FF = 11111111Concept questions
$1234 has high byte $12 and low byte $34.
One hexadecimal digit maps neatly to one nibble because both represent sixteen possible patterns or values: 0 through 15.
An 8-bit register has 256 possible bit patterns, representing unsigned values 0 through 255. Decimal 256 would require a ninth bit.
An address identifies a memory location; the byte stored at that address is the location's contents. They are not the same thing.
A is the accumulator and holds ordinary 8-bit working values. F is the flags register, whose individual bits report conditions produced by certain operations.
LD A,$42 loads a value but does not recalculate the arithmetic flags. ADD performs arithmetic and updates relevant flags to describe the result.
Common beginner confusions
If something goes wrong
The first tutorial should teach recovery as well as success. Most early problems are small and local.
A simple recovery routine
1. Stop adding new code.
2. Identify which environment you are in.
3. Save if Odin is still responsive.
4. Reassemble and read the first error carefully.
5. Fix one thing at a time.
6. Return to the last known-good source if necessary.
7. Only run again after ASSEMBLED OK.Making one small correction at a time is much easier to debug than changing several things at once.
More beginner questions worth answering explicitly
You are ready to finish Tutorial 1 if…
Do not interpret this as a test that must be passed perfectly. It is a self-check. You are ready to move on when you can explain most of these ideas in plain language:
- Why $42 is hexadecimal 66 rather than decimal 42.
- Why one byte is usually displayed as two hexadecimal digits.
- Why $6000 is a 16-bit value and can be held in HL.
- The difference between an address and the byte stored at that address.
- What it means to say that HL is being used as a pointer.
- What A and F mean when Odin displays AF.
- What the assembler does and what the CPU does.
- Why LD A,$42 becomes the machine-code bytes 3E 42.
- Why the next instruction does not necessarily begin one byte later.
- Why RET is needed in our tiny Odin-run routine.
- Why saving, assembling and running are three different actions.
- The difference between tut01.odn and tut01.asm.
Where Tutorial 1 stops
Tutorial 1 stops after the reader can create and preserve source, assemble a tiny routine, inspect its symbols and bytes, run it safely in Odin, read basic register output, and understand the number and memory concepts behind what is displayed.
We do not need to become fluent in the entire Z80 instruction set before finishing this chapter. Tutorial 2 can build on this foundation with registers, flags, the stack and program flow in greater depth.
Why this tiny program matters to the real project
The program is deliberately tiny, but the workflow is the same one we will use for real Next Asset Lab modules:
Later modules will be larger and more hardware-specific, but the development discipline remains the same.
Integration into Next Asset Lab
This chapter establishes the development habits that the real application will use: verify the actual Odin build, work in small testable steps, inspect what the assembler produced, and keep a plain-text source representation alongside the native Odin source.
No architecture change is required. This is a teaching-order correction: the foundations are now introduced before the tutorial relies on them.
Complete source listing at this stage
This source is still a teaching probe rather than a production subsystem. Its purpose is to make the accumulator, arithmetic, flags, addresses and machine-code bytes visible in Odin.
Mini-glossary for this chapter
Tutorial 1 completion checklist
Before moving on, you should be able to explain most of these ideas in your own words or know where to find them in this chapter.
- I can distinguish the NextZXOS / NextBASIC prompt, the Odin Monitor and the Odin Editor.
- I can launch Odin and identify the Dev.2k environment used by this project.
- I know that decimal, binary and hexadecimal are different notations for values.
- I know what a bit, nibble, byte and 16-bit value are.
- I understand why a byte is naturally shown as two hexadecimal digits.
- I can identify high and low nibbles and high and low bytes.
- I can convert simple hexadecimal values to decimal using a written method.
- I understand the difference between an address, contents and a pointer.
- I understand that the Z80 sees a 64K address space at one time.
- I understand that files on storage are not the same as machine-code bytes in RAM.
- I know that bytes gain meaning from context.
- I know the beginner roles of A, F, HL, PC and SP.
- I understand the common uses of the main Z80 registers without treating them as rigid rules.
- I can identify a label, mnemonic, operand, immediate value and comment.
- I understand that Odin assembles source and the Z80 executes machine code.
- I understand that Z80 instructions can occupy different numbers of bytes.
- I can create, edit and save a native Odin source file.
- I can assemble it and recognise ASSEMBLED OK.
- I can use T to inspect a symbol and M to inspect machine-code bytes.
- I can run the tiny routine with R and recognise the important register results.
- I understand at a beginner level why RET can return control to Odin.
- I can export ordinary text with TS and import it with TL.
- I know the difference between tut01.odn and tut01.asm.
- I know that an assembly error is useful diagnostic information.
Summary
You now have a foundation for understanding what Odin is showing rather than merely copying commands. The CPU fetches, decodes and executes machine-code bytes from memory. Decimal, binary and hexadecimal are different notations for the same values. Bits form nibbles and bytes; bytes form 16-bit values. Memory locations have addresses, and a pointer is a value used as an address. Registers contain working values inside the CPU. A is the accumulator, F contains individual flag bits, HL can be used as a pointer, PC controls instruction flow, and SP relates to the stack. Odin translates readable mnemonics and operands into the actual bytes that the Z80 executes.
The next stage should build on these foundations carefully: signed versus unsigned interpretation, the role of the main flags, simple comparisons and conditional branching. We should not introduce those topics until the number-system and register concepts in this chapter feel comfortable.
