Msi Assignment 2 (Fa22-Bee-014)
Msi Assignment 2 (Fa22-Bee-014)
Assignment # 02
Title:Microprocessor Programming with Unique Problem
Set
Submitted to:
Sir. Akbar Ali Khan Afridi
Submitted by:
Name:Daniyal Shabbir
Reg no:FA22-BEE-014
Date:October25 ,2024
Q: Data Transfer: Move the immediate value 0x1E to Register A and the value
from memory pointed by Register SI to Register C (indexed addressing).
Arithmetic: Add Register A and Register C, then multiply the result by the value
from Memory Address 220H.
Code :
segment .data
mem220h dw 0x10 ; Replace with the actual value at memory address 220H
segment .code
_start:
; Data Transfer
mov al, 0x1E ; Move immediate value 0x1E to register A (AL)
mov cx, [si] ; Move value from memory addressed by SI into register C
(CX)
; Arithmetic
add al, cl ; Add AL and CL (A and C registers)
mov ax, [mem220h] ; Move value from memory address 220H into AX
mul ax ; Multiply AL by AX (result in AX)
Output:
Explanation:
Understanding Addressing Modes:
Immediate Addressing Mode:
Instruction: mov al, 0x1E
In this instruction, the value 0x1E (which is a hexadecimal number) is directly provided in the
instruction and loaded into the AL register. This is known as immediate addressing because the
data is provided immediately in the instruction itself rather than from a memory location or
another register.
·Impact: The processor directly stores the value 0x1E into register A (AL), making it ready for
arithmetic operations.
b. Indexed Addressing Mode:
Instruction: mov cx, [si]
the program uses the indexed addressing mode. The value stored in the memory address
pointed to by the SI (Source Index) register is moved into the CX register. This means the actual
memory location is determined by the contents of the SI register, which acts as an offset into
memory.
Impact: The program can dynamically access data from memory by adjusting the value of SI.
This allows for flexibility in data retrieval without hardcoding specific memory addresses.
Instruction: mul ax
The mul instruction performs an unsigned multiplication between the contents of AL and AX.
After the addition in the previous step, the result in AL is multiplied by the value loaded from
memory address 220H (stored in AX).
Impact: This logical operation multiplies two values, and the result is stored in the AX
register. The operation can affect the Overflow Flag and Carry Flag, which indicate
whether the result was too large to fit in the destination register.