MP CH 6
MP CH 6
Glo~sary
AND coiuUtloa
.. A logical AND of two conditions
coaclltlonal jump A jump Instruction whose execution
iD.structlOD depends on status flag settings
loop A sequence of instructions that is repeated
OR coaclltlon A logical OR of two conditions
signed jump A conditional jump instruction used with
signed numbers
single-Dag jump A conditional jump that operates on the
setting of an individual status flag
top-clown program design Program development by breaking a large
problem Into a series of smaller problems
unconclltlonal j~mp An unconditional transfer of control
unsigned jump A conditional jump instruction used with
unsigned numbers
New Instructions
CMP JCXZ JLE/JNG
JA/JNBE JE/JZ JMP
JAE/JNB JG/JNLE JNC
JB/JNAE JGE/JNL JNE/JNZ
JBE/JNA JL/JNLE LOOP
JC
Exercises
1. Write asse~bJy.c~.e for ~ach of the following decision structures.
a. ·IF AX < 0
THEN
PUT -1 IN BX
END IF
b. IF "AL < 0
THEN
put FFh in AH'
ELSE
put 0 in AH
END_IF
d. IF AX < BX
THEN
IF BX i<
ex
THEN
114 Exer<;ises.
t'ut 0 in AX.
ELSE ''l~
put 0 iii BX
END_IF ·:.. -·
END_IF
f. IF AY. < BX
THEN
put 0 ·in AX
ELSE
IF BY. < C'X
THEN
put 0 in BX
ELSE
put ·o in ex
END IF
END IF
initialize product to O
REPEAT
add M to product
decrement N
UNTIL N z 0
Programming Exercises
8. Write a program to display a "?", read two capital letters, and dis-
play them on the next line In alphabetical order.
9. Write a program to display the extended ASCII characters (ASCJI
codes 80h to FF_h). Display 10 characters per line, separated by
blanks. Stop after the extended characters have been displayed
once.
10. Write a program that will prompt the user to enter a hex digit
character ("0"· ... "9" or "A" ... "F"), display it on the next line
in decimal, and ask the user i.i he or she wants to do it again. If
the user types "y" or "Y", the ·program repeats; If the user types
anything else, the program terminates. If the user enters an illegal
character, prompt the user to try again.
Sample exen1tiot1: :-
116 Programf'(ling Exercises