MGMT 1000 Lecture Notes - Lecture 18: Mnemonic

22 views2 pages
MGMT 1000 Tutorial 18 Notes Branches and Loops
Introduction
Instructions of this type are used to perform branches and loops.
As an example, consider the following WHILE-DO loop, common to many programming
languages: WHILE Value = 0 DO Task
Next Statement
This loop could be implemented using the Little Man BRANCH instruction as follows.
Assume that these instructions are located starting at mailbox number 45 (comments
are provided to the right of each line)
45 LDA 90 590 90 is assumed to contain value 46 BRZ 48 748
Branch if the value is zero 47 BR 60 660 Exit loop
Jump to Next Statement 48
This is where the task is located 59 BR 45 645 End to Task
Loop to test again 60
EXAMPLE
Here is an example of a Little Man program that uses the BRANCH instructions to alter
the flow of the program.
This program finds the positive difference between two numbers (sometimes known as
the absolute magnitude of the difference).
For convenience, we are introducing a set of abbreviations for each instruction.
These areiatios are ko as eois the first  is silet. Oe you lear to
read these eois, youll fid that progras ritte ith eois are geerally
easy to read.
It is more common to write programs this way.
For a while, we will continue to print both the mnemonic and the code.
Eventually, we will stop printing the code.
Most programs are also written with comments, which help to clarify the code.
The mnemonic instructions that we will use are shown
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents