4.4 Flow of Control
- Read about the following instructions, pay attention to the flags used
by the instructions.
ADD
: Add
BT
, BTC
, BTR
, & , BTS
: Bit Test
CMP
: Compare Integers
DEC
: Decrement
INC
: Increment
Jcc
: Conditional branch
JCXZ
& JECXZ
: Jump if CX/ECX is zero
JMP
: Jump -- unconditional
LOOPxx
: Loop with counter
SUB
: Subtract
CMOVcc
: Conditional MOV
instruction.
- Structured code
if(
expression )
statement
if(
expression )
statement else
statement
for(
expression;
expression;
expression)
statement
while(
expression )
statement
do
statement while(
expression )
break
, continue
, next
, & redo
- later: multi-way branch
switch
-- case
Write a program in assembly language that:
- Prints your name, class (CIS250) and the date.
- Print out "Factorial Series"
- Compute and print the first 10 values of the factorial series.
It starts like 1, 2, 6, 24, 120, .... This program uses the
for
statement construct.
- Print out another header "Fibonacci"
- Prints out the first 20 Fibonacci
number along with their index. Keep computing more numbers until an arithmetic
carry occurs (unsigned overflow). While you do this print every fifth (5th)
number. Also print the
last number computed and its index before the carry (unsigned overflow) occurred.
This section will
us
INC
, ADD
, CMP
, and Jcc
to approximate
both if
statements and a do
statement. The sequence starts like
this 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987
Turn in a printed error free listing and the output of your program.
Include a copy of any testing that you did to verify the program was correct.
For this lab, use a spreadsheet to help your testing.
Instructor: Louis Taber, louis.taber.at.pima at gmail dot com (520) 206-6850
My web site in California
The Pima Community College web site