Above is a Little Man Computer (LMC) simulator. The original LMC uses denary instructions, but I created this one to use binary instead to more closely model what happens in a CPU. It has a 5bit address bus and an 8bit data bus. All instructions are 8bits with direct addressing as the only addressing mode. Memory is limited to 32 x 8bit slots for 32bytes total memory.
Binary LMC instruction set
|Store value from accumulator to memory address xxxxx
|Load value from memory address xxxxx into accumulator
|Add contents of memory address xxxxx to accumulator
|Subtract contents of memory address xxxxx from accumulator
|Branch to memory address xxxxx, unconditionally
|Branch to memory address xxxxx if accumulator is zero
|Branch to memory address xxxxx if accumulator is positive (or zero)
|Input from user into accumulator (xxx not used)
|Output value of accumulator to the output box (xxx not used)
|Terminates execution of the program
|A memory location that contains data (an integer from -128 to 127)
The instruction set is the same as for the denary LMC - programs written in LMC assembly should work fine. Lines of assembly start with an optional label, then have one of the 11 mnemonics, then an optional value (which could be a denary integer or the name of a label defined on another line). Example program:
INP # user inputs a value STA a # which is stored into 'a' INP # user inputs another value ADD a # which has 'a' added to it OUT # and is then output HLT # program terminates a DAT # ... location to store 'a' # Not used in this program... b DAT 34 # put '34' in memory labelled 'b'
Data is 8bit signed integers in 2s-complement, between -128 and +127.
You may like other cool free things I've made.