Commands Little man computer
1 commands
1.1 instructions
1.2 examples
1.2.1 using numeric instruction codes
1.2.2 using mnemonics , labels
commands
while lmc reflect actual workings of binary processors, simplicity of decimal numbers chosen minimize complexity students may not comfortable working in binary/hexadecimal.
instructions
some lmc simulators programmed directly using 3-digit numeric instructions , use 3-letter mnemonic codes , labels. in either case, instruction set deliberately limited (typically ten instructions) simplify understanding. if lmc uses mnemonic codes , labels these converted 3-digit numeric instructions when program assembled.
the table below shows typical numeric instruction set , equivalent mnemonic codes.
examples
using numeric instruction codes
this program (instruction 901 instruction 000) written using numeric codes. program takes 2 numbers input , outputs difference. notice execution starts @ mailbox 00 , finishes @ mailbox 07. disadvantages of programming lmc using numeric instruction codes discussed below.
using mnemonics , labels
assembly language low-level programming language uses mnemonics , labels instead of numeric instruction codes. although lmc uses limited set of mnemonics, convenience of using mnemonic each instruction made apparent assembly language of same program shown below - programmer no longer required memorize set of anonymous numeric codes , can program set of more memorable mnemonic codes. if mnemonic instruction involves memory address (either branch instruction or loading/saving data) label used name memory address.
this example program can compiled , run on lmc simulator available on website of york university (toronto, ontario, canada) or on desktop application written mike coley. these simulators include full instructions , sample programs, assembler convert assembly code machine code, control interfaces execute , monitor programs, , step-by-step detailed description of each lmc instruction.
inp
sta first
inp
sta second
lda first
sub second
out
hlt
first dat
second dat
Comments
Post a Comment