0% found this document useful (0 votes)
51 views3 pages

Assembly Language Program - Part IV: 1. Multiple Initializers

This document discusses assembly language programming concepts including multiple data initializers, direct and indirect addressing, and unconditional jumps and loops. It provides examples of defining data with multiple initializers and different radixes. Direct offset addressing allows accessing memory locations with explicit labels. Indirect addressing uses a register containing a memory offset. The JMP instruction unconditionally transfers control. LOOP repeats a block while decrementing the CX register as a counter.

Uploaded by

black hello
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views3 pages

Assembly Language Program - Part IV: 1. Multiple Initializers

This document discusses assembly language programming concepts including multiple data initializers, direct and indirect addressing, and unconditional jumps and loops. It provides examples of defining data with multiple initializers and different radixes. Direct offset addressing allows accessing memory locations with explicit labels. Indirect addressing uses a register containing a memory offset. The JMP instruction unconditionally transfers control. LOOP repeats a block while decrementing the CX register as a counter.

Uploaded by

black hello
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

BACS1024 Introduction to Computer Systems

Assembly Language Program - Part IV


1. Multiple Initializers
2. Direct Offset Addressing
3. Indirect Addressing

1. Multiple Initializers

1) A data definition may have multiple initializers.

2) Each initializer is referred by its offset.

3) If a data definition has multiple initializers, the label is the offset for the first item.

4) E.g.: List DB 10, 20, 30, 40, 50


List[0] / List+0 / List = 10
List[1] = 20
List[2] = 30

5) More examples:
A DB 10H
B DB 10H, 20H, 30H
C DW 10H,20H ;C=0010H,0020H
PRI DB 2,4,6,8

Memory
Variable Data segment Offset address

08H

06H

PRI[1] 04H

PRI=PRI[0] 02H 0008H

00H

C=[1] 20H 0006H

00H

C=C[0] 10H 0004H

B[2] 30H 0003h

B[1] 20H 0002h

B=B[0] 10H 0001h

A 10H 0000h

1
BACS1024 Introduction to Computer Systems

6) Different initializers can use different radixes.


 E.g.: VAR1 DB 10, 25, 41H, 0010 0010B
VAR2 DB 0BH, 'A', 60

7) DUP operator
 Allocates storage for multiple data items, using a constant expression as a
counter.
 It is useful when allocating space for a string array and can be used with
initialized and uninitialized data.
 E.g.: VAR1 DB 20 DUP (0)
VAR2 DB 30 DUP (?)
VAR3 DB 2 DUP ("HELLO")
VAR4 DB 3, 2 DUP (1, 2 DUP ("*"),2)

2. Direct Addressing

Addressing
1) A direct offset operand could be created by adding a displacement /offset to the
name of the variable.

2) It enables access to memory locations that may have explicit labels.


 E.g.:
.DATA
VAR DB "A", "B", "C","D","E"
.CODE
MOV AL,VAR ; AL="A"
MOV BL,[VAR+1] ; BL="B"
MOV CL,VAR[2] ; CL="C"

3. Indirect Addressing

1) An indirect operand is a register containing the offset of the data in the memory
location.

2) If the register is used as an indirect operand, it may only be SI, DI, BX or BP.
Avoid BP unless it is using to index into the stack.
 E.g.:
.DATA
VAR DB "A", "B", "C","D","E"
.CODE
LEA DX,VAR
MOV AL,[DX]

3) Unconditional processing
a) JMP instruction
 Transfer control under all circumstances.
 Allow transfer of control to the target address.
 Format:
JMP destination
 E.g.:
(i) Forward jump

2
BACS1024 Introduction to Computer Systems

JMP L1
L1:

(ii) Backward jump
L1:
JMP L1

b) LOOP instruction
 Repeats a block of statements a specific number.
 CX is automatically used as a counter and is decremented each time the
loop repeats.
 E.g.:
MOV CX,3
SUM:
INC AX
LOOP SUM
 E.g.: Nested loop
.DATA
COUNT DW ?
NL DB 13,10,"$"
.CODE
MOV CX,5
L1:
MOV COUNT,CX
MOV CX,3
L2:
MOV AH,02H
MOV DL,"*"
INT 21H
LOOP L2

MOV AH,09H
LEA DX,NL
INT 21H

MOV CX,COUNT
LOOP L1

You might also like