Professional Documents
Culture Documents
Activity No 2 Registers
Activity No 2 Registers
2
Registers
Course Code: CPE 021 Program:
Course Title: Computer Architecture and Organization Date Performed:
Section: Date Submitted:
Name: Instructor:
1. Objective:
This activity aims to demonstrate how the CPU registers are used for addition, subtraction,
multiplication and division operations and how the flag register are affected by these operations
The 8088 CPU for example, has fourteen 16 bit registers to process the data in a computer.
The general-purpose registers are primarily used for arithmetic and data movement. Each register can
be addressed as either a single 32-bit value or two 16-bit values. Portions of some registers can be
addressed as 8-bit values.
For example, the 32-bit EAX register has a 16-bit lower half named AX. The AX register, in turn, has
an 8-bit upper half named AH (A-High) and an 8-bit lower half named AL(A-Low).
The same overlapping relationship exists for the EAX, EBX, ECX, and EDX registers.
The remaining general-purpose registers only have specific names for their lower 16 bits, these are
used when writing real-address mode programs.
THE FLAGS
The EFLAGS (or just Flags) register consists of individual binary bits that control the operation of the
CPU or reflect the result of arithmetic and logical instructions. Some instructions test and manipulate
individual processor flags.
A flag is set when it equals 1; it is clear (or reset) when it equals 0. Figure 2-1 shows how each flag is
represented by DEBUG.
The operands can be considered as signed numbers or unsigned numbers. The unsigned multiplication
and division operations are MUL, DIV.
Sample Problem B:
1. Open Debug.exe
2. Assemble the following program:
-A 100
movax,ffff
add ax,01
int 21
3. Trace the values of the registers starting at address 0100
-T=100 2
4. Observe the output.
What did you observe in the output? Why?
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
5. Record all results in Table 2.5.
6. Reset the values of the registers.
Sample Problem C.
1. Open Debug.exe.
2. Assemble the following program:
-A 100
mov al,00
sub al,01
int 21
2. Trace the values of the registers.
3. Observe the output.
Which flag/flags was/were affected by the given? Why?
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
4. Record all results in Table 2.6.
5. Reset the values of the registers.
Sample Problem D.
1. Open Debug.exe.
2. Assemble the following program:
-A 100
mov al,0a
mov bl,05
mulbl
int 21
7. Trace the values of the registers.
8. Observe the output.
What did you observe in the output? Why?
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
9. Record all results in Table 2.7.
10. Reset the values of the registers.
Sample Problem E.
1. Open Debug.exe.
2. Assemble the following program:
-A 100
mov dx,0
mov ax,8003
mov cx,100
div cx
int 21
3. Trace the values of the registers.
4. Observe the output.
What did you observe in the output? Why?
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
5. Record all results in Table 2.8.
6. Reset the values of the registers.
6. DATA ANALYSIS:
Table 2.4- Result of Sample Problem A.2
AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=_______ ES=_______ SS=_______ CS=_______ IP=0100 NV UP EI PL NZ NA PO NC
Instruction AX BX CX
Register DX
Content IP Flag Register
MOV AL,0a AX BX CX DX IP
MOV
MOV BL,05
AX,FFFF
MUL BL
ADD AX,01
INT
INT 21h
21h
DIV CX
INT 21h
7. PROBLEMS:
1. Determine two 8-bit numbers that will cause the following flag conditions to occur after the addition.
Verify that your numbers cause thespecified flag conditions by modifying your program with your
new numbers, executing it, andrecording the flag values. Use HEX numbers.
a. Carry = 0, Overflow = 0, Zero = 0, Sign = 0: ___________ + ___________ = ___________
b. Carry = 0, Overflow = 0, Zero = 0, Sign = 1: ___________ + ___________ = ___________
c. Carry = 1, Overflow = 1, Zero = 0, Sign = 0: ___________ + ___________ = ___________
d. Carry = 0, Overflow = 1, Zero = 0, Sign = 1: ___________ + ___________ = ___________
e. Carry = 1, Overflow = 0, Zero = 0, Sign = 1 : ___________ + ___________ = ___________
f. Carry = 1, Overflow = 0, Zero = 0, Sign = 0 : ___________ + ___________ = ___________
g. Carry = 0, Overflow = 0, Zero = 1, Sign = 0 : ___________ + ___________ = ___________
8. CONCLUSIONS