Litte Man Computer

  1. Reference
  2. Little Man Computer - Simulator -1
  3. Little Man Computer - Simulator -2

Examples


Sum all entered numbers until a 0 is entered, then print the sum
bucket# Instruction 0 9,01 //9=READ AND ENTER INTO CALCULATOR 1 7,05 //7=BZ/BRANCH IF ZERO. IF READ WAS ZERO, GOTO BUCKET 5 2 1,08 //1=ADD BUCKET 8 TO EXISTING VALUE (SUM) IN CALCULATOR 3 3,08 //3=STORE THE SUM IN BUCKET 8 (REPLACE EXISTING CONTENT IN BUCKET 8) 4 6,00 //6=GO BACK TO BUCKET 0, PROGRAM COUNTER = 00 (that is to say, 0) 5 5,08 //5=LOAD FROM BUCKET 8 6 9,02 //9=PRINT VALUE IN CALCULATOR 7 0,00 //0=STOP 8 ?,00 //Temporary Storage Bucket, '?' doesn't matter, VALUE = 00 to START WITH

Add 2 numbers
INP STA FIRST INP STA SECOND LDA FIRST ADD SECOND OUT HLT FIRST DAT SECOND DAT
Take a number and count down to zero from that number
INP OUT // Initialize output LOOP BRZ QUIT // If the accumulator value is 0, jump to the memory address labeled QUIT SUB ONE // The instruction will then subtract the value stored at address ONE from the accumulator OUT BRA LOOP // Jump (unconditionally) to the memory address labeled LOOP QUIT HLT // Label this memory address as QUIT ONE DAT 1 // Store the value 1 in this memory address, and label it ONE (variable declaration)