; LMC Sample Program (from class) ; -IAN! idallen@ncf.ca ; ; We will use this 6-column format for all LMC programs. ; We won't use the Label column yet. ; ; The "DAT" (data) mnemonic is not an LMC instruction. It is used by ; assembler programmers to indicate that the given operand is data ; to be placed in memory at this location. ; ; Input Queue (for "IN" statements): ; 324 ; 119 ; 041 ; ; Output: 484 ; ;Loc. Code Label Mnemon. Operand Comments ;---- ---- ----- ------- ------- ------------------------- 00 500 IN ; input a number 01 312 ADD 12 ; add sum to number 02 212 STO 12 ; store back into sum 03 113 LDA 13 ; load counter 04 411 SUB 11 ; subtract one 05 213 STO 13 ; store back in counter 06 801 SKZ ; exit loop if counter is zero 07 900 JMP 00 ; go to top of loop 08 112 LDA 12 ; load sum 09 600 OUT ; output sum 10 700 HLT ; go to sleep 11 001 DAT 001 ; constant 1 12 000 DAT 000 ; sum 13 003 DAT 003 ; counter 14 500 DAT 500 ; junk