Lab 2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

MICROPROCESSOR SYSTEMS

NAME: SUBJECT CODE: Q178

LABORATORY WORK NO. 2


ARITHMETIC AND LOGIC INSTRUCTIONS
I. OBJECTIVE(S):
-

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 ax, @data

mov ds, ax

mov ax, num1

add ax, num2

mov ah, 09h

int 21h

mov ax, 0

mov cx, 10

rol ax, 1

mov dx, 0

add dl, '0'

mov ah, 02h

int 21h

mov ah, 4Ch

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

OUTPUT EMULATOR SCREEN:


3. Stacks:
- is the order in which individual statements, instructions or function
calls of an imperative program are executed or evaluated.

SAMPLE PROGRAM:

org 100h

msg db 'Hello, Stack!', 0

mov ax, @data

mov ds, ax

lea dx, [msg]

push dx

call print_string_from_stack

mov ah, 4Ch

int 21h

print_string_from_stack:

pop dx

mov ah, 09

int 21h

re

OUTPUT EMULATOR SCREEN:

4. Program flow control :


- is the order in which individual statements, instructions or function
calls of an imperative program are executed or evaluated.
SAMPLE PROGRAM:

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

OUTPUT EMULATOR SCREEN:

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).

2. ADD INSTRUCTION, SUBSTRACT INSTRUCTION, AND MULTIPLICATION/DIVISON


INSTRUCTIONS.

3. Basic Logic Instructions and MIPS Logic Instructions and

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.

You might also like