Documentos de Académico
Documentos de Profesional
Documentos de Cultura
EXPERIMENT 7
PROCESSING ASCII & BCD DATA
I. OBJECTIVE
1. To examine ASCII and BCD data formats.
2. To perform arithmetic and to cover conversions between these formats and
binary.
II. INSTRUCTIONS / SERVICES
A.
o
o
o
o
Note: These instruction are coded without operands and automatically adjust the AX
register.
B. ASCII Addition
The AAA/AAS operations check the rightmost hex digit (4 bits) of the AL register. If
the digit is between A to F or the auxiliary carry flags is 1, the operation adds 6 to the
AL register, adds 1 to the AH register, and sets the carry auxiliary carry flags to 1.
Consider the effect of adding the ASCII number 8 and 4;
0038H
0034H
AX
BX
C. ASCII Subtraction
Consider the following:
hex 38
hex 34
AX
mov al, asc1
sub al, asc2
AAS
1 | Page
asc1
asc2
F
; 0038
; 0004
; 0004
0
0
D. ASCII Multiplication
The AAM instruction corrects the result of multiplying ASCII data in the AX register. It
divides the AL by 10 (hex 0A) and stores the quotient in the AH and the remainder in
the AL.
Consider the following:
hex 35
AL
hex 39
CL
and cl, 0Fh ; convert cl to 09
and al, 0Fh ; convert al to 05
mul cl
; multiply al by cl
AAM
; convert to unpacked decimal
or ax, 3030h ;convert to ASCII
E. ASCII Division
The AAD instruction provides a correction of an ASCII dividend prior to dividing. It
allows for a two bytes dividend in the AX.
Consider the following:
hex 3238
hex 37
and CL, 0Fh
AAD
div CL
2 | Page
AX (dividend)
CL (divisor)
;convert to unpacked 0208
; convert to binary
; divide by 7
EXERCISE
NAME:
INSTRUCTOR:
SECTION:
DATE:
GRADE:
mov bx, ax
mov ah, 09
lea dx, msg
int 21h
mov
mov
int
mov
mov
int
ah,02
dl, bh
21h
ah, 02
dl, bl
21h
int 20h
cseg ends
end start
Try to change the values (single digit only) of num1 and num2 and observe the value on
the output message. What does the program perform?
3 | Page
4 | Page
ah, 02h
dl, tens
21h
dl, ones
21h
int 20h
cseg ends
end start
5 | Page
mov ah,00h
aaa
mov z, al
add
add
mov
mov
aaa
bh,ch
bh,ah
al,bh
ah,00h
mov y, al
mov x, ah
add z, 30h
add y, 30h
add x, 30h
mov ah, 09h
lea dx, str3
int 21h
mov
mov
int
mov
int
mov
int
ah,
dl,
21h
dl,
21h
dl,
21h
02h
x
y
z
int 20h
cseg ends
end start
ACTIVITY
NAME:
SECTION:
DATE:
INSTRUCTOR:
GRADE:
Create a program in assembly language that will let the user input two 2-digit numbers
and then an operation (+ or -), the program will then compute for the appropriate total
for the given inputs.
6 | Page