Toggle Navigation
Hatchery
Eggs
lmc
README.md
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
README.md
raw
Content
# Little Man Computer This is a simulator for a [Little Man Computer](https://en.wikipedia.org/wiki/Little_man_computer). It can be used as an educational toy. ## How it works The screen consists of 4 parts: * Memory/code editor (the large area at the bottom) * Accumulator (top-left corner) * Dot display (top-middle) * Output console (top-right) You enter machine codes into memory and run it: * DPAD UP/LEFT/DOWN/RIGHT: navigate the memory editor * A/B: enter input dialog * START: run the program from the current position * MENU: exit * HOME: go to cell at address 0 and reset the display, dots, LEDs etc When the program is running: * START: stop the program * Other keys are regular input to the program. When the input dialog is shown: * DPAD LEFT/RIGHT: navigate digits * DPAD UP/DOWN: increase current digit * A: Save value * B: Cancel ## Instruction set * 000 - HLT - Halt (stop) the program * 1xx - ADD xx - Add contents of cell `xx` to the accumulator * 2xx - SUB xx - Subtract contents of the cell `xx` from the accumulator * 3xx - STA xx - Store accumulator value to the cell `xx` * 4nn - STI xx - Store value from cell `xx` into a cell pointed by the accumulator * 5xx - LDA xx - Load cell `xx` contents into accumulator * 6xx - JMP xx - Jump execution to cell `xx` * 7xx - JPP xx - Jump to cell `xx` if accumulator is not negative * 8xx - JPZ xx - Jump to cell `xx` if accumulator is zero * 901 - INP - Show input dialog and put input value into accumulator * 902 - OUT - Display accumulator contents into the output window * 903 - ON - For accumulator value xx - turn dot #xx on * 904 - OFF - For accumulator value xx - turn dot #xx off * 905 - LED - For accumulator value xy - set LED #x to color #y * 906 - KEY - Load pressed keys into accumulator (as bits) * 907 - PLAY - For accumulator value xy - play note #x for #0.y seconds * 91x - SLEEP - Sleep for 0.x seconds * 999 - LDI - For accumulator value xx - load cell #xx contents into the accumulator Other instructions are no-ops. Also, cell #99 on every step contains a random number. ## Example programs Add two numbers: ``` 901 306 901 106 902 ``` Blink a LED: ``` 507 905 915 208 905 915 600 12 2 ``` Move a dot: ``` 506 903 913 904 107 601 0 1 ``` Multiply numbers: ``` MUL = [901,320,901,321,522,120,322,521,223,321,804,522,220,322,902,0,0,0,0,0,0,0,0,1] ``` Play music from a list of notes (indirect addressing): ``` 510 999 708 907 510 111 310 601 0 0 20 1 0 0 0 0 0 0 0 0 52 52 52 22 32 32 24 72 72 62 62 55 0 ```