In: Computer Science
Write LMC assembly code that prints the minimum of two numbers.
HINT: use and extend the table below for your solution.
Mailbox |
Mnemonic |
Code |
Instruction description |
Little Man Computer - LMC - is a simulator that
mimics the modern computer architecture, known as von
Neumann architecture.
Von Neumann Architecture
The Von Neumann architecture, illustrated in the following
image, consists of five major components with machine equivalent of
division of labour.
They are,
Input-Output Unit
The unit allows a user interact with the computer while providing
it with an input in anticipation of an output.
Control Unit
This unit deals with the handling of instructions, processing of
the data, storing it in memory and reading it back from it at the
right moment.
Logic Unit
This unit is responsible for carrying out basic mathematical
operation such as addition, subtraction etc.
Memory
This section stores data and the instructions to deal with
data.
BUS
This is the machine equivalent of umbilical chord - the connector
of the other four parts to the motherboard.
LMC assembly code that prints the minimum of two numbers.
INP
STA first
INP
STA second
SUB second
BRP secondBig
LDA second
OUT
BRA endProgram
secondBig LDA second
OUT
endProgram HLT
first DAT
second DAT
Mailboxes:
First, there is a series of one hundred mailboxes, each numbered with an address ranging from 00 to 99. This numbering system is chosen because each mailbox address can be represented by two digits, and this is the maximum number of mailboxes that can be represented by two decimal digits.
Each mailbox is designed to hold a single slip of paper, upon which is written a three-digit decimal number. Note carefully that the contents of a mailbox are not the same as the address of a mailbox. This idea is consistent with what you already know about your post office box: your post office box number .
Mnemonic Code:
A code that can be remembered comparatively easily and that aids its user in recalling the information it represents. ... Mnemonic codes are widely used in computer programming and communications system operations to specify instructions.
Mailboxes: | Mnemonic code | Instruction specification |
INP | 901 | Input data |
SUB | 1xx | substract data |
LDA | 2xx | load the data |
OUT | 3xx | output data |
BRA | 4xx | Branch to specified cell |
HLT | HLT | Break Execution |
DAT | Treat code as data |