Lab Manual 3
Lab Manual 3
Course Instructor:
Lab Instructor:
In assembly language, data is often manipulated in units called bytes and words. A byte consists of
8 bits, while a word is typically 16 bits (or 2 bytes). These are the fundamental units of data, and in-
structions can operate on either, depending on the size of the data to be processed.
The iAPX80 and iAPX88 processors from Intel feature a set of registers that are used for various
tasks, such as arithmetic, data movement, and memory addressing. These registers can be accessed
as 8-bit (byte) or 16-bit (word) units.
AX, BX, CX, DX: General-purpose registers, which can be used as 16-bit (AX) or split into
two 8-bit registers (AH and AL).
SI, DI: Source and destination index registers for memory operations.
Flags Register: Contains flags that reflect the outcome of arithmetic and logic operations.
IP (Instruction Pointer): Holds the address of the next instruction.
Addressing Modes
Addressing modes in assembly language define how the operands of instructions are accessed. These
modes allow the processor to interpret whether data is in a register, memory, or an immediate value
embedded in the instruction.
Immediate Addressing: The operand is a constant value embedded directly in the instruction
(e.g., mov ax, 5).
Direct Addressing: The operand refers to a specific memory location (e.g., mov ax,
[1000h]).
Register Addressing: Operands are located in registers (e.g., mov ax, bx).
Indirect Addressing: Memory addresses are indirectly referenced via a register (e.g., mov
ax, [bx]).
Declaring Data in Assembly
In assembly language, data is declared using directives like db (define byte) for 8-bit data and dw
(define word) for 16-bit data. These directives reserve space in memory and initialize it with a spe-
cific value.
Sample Programs
1. Byte Register Example (Data Movement and Addition)
This program demonstrates moving byte-sized data between registers using immediate addressing
and performing addition:
[ORG 0x100]
mov al, 5 ; Move 5 into AL (byte-sized)
mov bl, 10 ; Move 10 into BL (byte-sized)
add al, bl ; Add BL to AL, result in AL
mov ah, 0x4C ; Terminate program
int 0x21 ; DOS interrupt
This program shows moving word-sized data between registers using immediate addressing and per-
forming subtraction:
[ORG 0x100]
mov ax, 1000 ; Move 1000 into AX (word-sized)
mov bx, 500 ; Move 500 into BX (word-sized)
sub ax, bx ; Subtract BX from AX, result in AX
mov ax, 0x4C00 ; Terminate program
int 0x21 ; DOS interrupt
This program shows moving word-sized data between registers and memory using direct addressing
and performing addition:
[ORG 0x100]
mov ax, [Num1] ; move the first number in ax
mov bx, [Num2] ; move the second number in bx
add ax, bx ; add first and second numbers in ax
mov bx, [Num3] ; move the third number in bx
add ax, bx ; add the third number to ax
mov [Num4], ax ; move the sum to location Num4
Num1: dw 5
Num2: dw 10
Num3: dw 15
Num4: dw 0
Practice Questions