Professional Documents
Culture Documents
Lab 2
Lab 2
II. THEORIES:
1. Arithmetic instructions:
- define the set of operations performed by the processor Arithmetic Logic Unit (ALU). The
arithmetic instructions are further classified into binary, decimal, logical, shift/rotate,
and bit/byte manipulation instructions.
SAMPLE PROGRAM:
org 100h
num1 dw 10
num2 dw 5
mov ds, ax
int 21h
mov ax, 0
mov cx, 10
rol ax, 1
mov dx, 0
int 21h
int 21h
OUTPUT EMULATOR SCREEN:
2. Logical instruction:
- instructions which perform basic logical operations such as AND, OR, etc. In 8086
microprocessor, the destination operand need not be the accumulator.
SAMPLE PROGRAM:
ORG 100h
.MODEL SMALL
.CODE
MOV BX,3527
MOV CX,2968
AND BX,CX
RET
SAMPLE PROGRAM:
org 100h
mov ds, ax
push dx
call print_string_from_stack
int 21h
print_string_from_stack:
pop dx
mov ah, 09
int 21h
re
org 100h
jmp $3+2
a db 3
b db 4
c db 4
mov bl,9
dec bl
cmp bl, 0
jne $-5
ret
III. QUESTIONS.
1. List types of flag register and their definitions.
2. What are the 3 groups of instructions for arithmetic instruction?
3. Identify the different types of logical instruction.
4. What is a stack?
IV. ANSWERS:
1. Flag registers are special registers within a processor that store single-bit information about the
status of various operations. The specific types and definitions vary depending on the specific processor
architecture, but some common ones include:
Carry Flag (CF): This flag indicates whether an arithmetic operation (addition or subtraction)
resulted in a carry out of the most significant bit (MSB).
Zero Flag (ZF): This flag indicates whether the result of an operation is zero.
Sign Flag (SF): This flag indicates the sign of the result (1 for negative, 0 for positive or zero).
Overflow Flag (OF): This flag indicates whether an arithmetic operation resulted in an
overflow, meaning the result is too large or too small to be represented correctly.
Parity Flag (PF): This flag indicates whether the number of 1 bits in the result is even or odd
(depending on the architecture).
4. Stack is an array or list structure of function calls and parameters used in modern computer
programming and CPU architecture. Similar to a stack of plates at a buffet restaurant or cafeteria,
elements in a stack are added or removed from the top of the stack, in a “last in first, first out” or LIFO
order.