67 lines
2.1 KiB
Markdown
67 lines
2.1 KiB
Markdown
## IBM Logo program
|
||
|
||
Theorically we only need these instructions to decode the whole program:
|
||
|
||
- 00E0 (clear screen)
|
||
- 1NNN (jump)
|
||
- 6XNN (set register VX)
|
||
- 7XNN (add value to register VX)
|
||
- ANNN (set index register I)
|
||
- DXYN (display/draw)
|
||
- This is the most involved instruction. It will draw an N pixels tall sprite
|
||
from the memory location that the I index register is holding to the screen,
|
||
at the horizontal X coordinate in VX and the Y coordinate in VY. All the pixels
|
||
that are “on” in the sprite will flip the pixels on the screen that it is drawn
|
||
to (from left to right, from most to least significant bit). If any pixels on
|
||
the screen were turned “off” by this, the VF flag register is set to 1.
|
||
Otherwise, it’s set to 0.
|
||
|
||
## Binary
|
||
1. 00E0 Clear SCREEN
|
||
2. A22A Set Register I to 0x22A
|
||
3. 600C Set Register 0 to 0xC
|
||
4. 6108 Set Register 1 to 0x8
|
||
5. D01F Draw
|
||
- Register[0] = 0xC
|
||
- Register[1] = 0x8
|
||
- N ( how tall is the sprite ) = 0xF
|
||
- Register[I] = 0x22A
|
||
6. 7009 Add 0x9 to Register 0 (new value is 0x15)
|
||
7. A239 Set Register I to 0x239
|
||
8. D01F Draw
|
||
- Register[0] = 0x15
|
||
- Register[1] = 0x8
|
||
- N ( how tall is the sprite ) = 0xF
|
||
- Register[I] = 0x239
|
||
9. A248 Set Register I to 0x248
|
||
10. 7008 Add 0x8 to Register 0 (new value is 0x1D)
|
||
11. D01F Draw
|
||
- Register[0] = 0x1D
|
||
- Register[1] = 0x8
|
||
- N ( how tall is the sprite ) = 0xF
|
||
- Register[I] = 0x248
|
||
12. 7004 Add 0x4 to Register 0 (new value is 0x21)
|
||
13. A257 Set Register I to 0x257
|
||
14. D01F Draw
|
||
- Register[0] = 0x21
|
||
- Register[1] = 0x8
|
||
- N ( how tall is the sprite ) = 0xF
|
||
- Register[I] = 0x257
|
||
15. 7008
|
||
16. A266 Set Register I to 0x266
|
||
17. D01F Draw
|
||
- Register[0] = 0x21
|
||
- Register[1] = 0x8
|
||
- N ( how tall is the sprite ) = 0xF
|
||
Register[I] = 0x266
|
||
18. 7008 Add 0x8 to Register 0 (new value is 0x29)
|
||
19. A275 Set Register I to 0x275
|
||
20. D01F Draw
|
||
- Register[0] = 0x29
|
||
- Register[1] = 0x8
|
||
- N ( how tall is the sprite ) = 0xF
|
||
- Register[I] = 0x275
|
||
21. 1228 Set program counter to 0x228
|
||
22. From this point onwards I think it is sprite data
|
||
|