Assembly Language Lab #1: Islamic University of Gaza Computer Engineering Department
Assembly Language Lab #1: Islamic University of Gaza Computer Engineering Department
Assembly Language Lab #1: Islamic University of Gaza Computer Engineering Department
2009
Assembly Language Lab #1
AH
BH
CH
DH
AL
BL
CL
DL
SP
BP
SI
DI
IP
Flags
ES
CS
DS
SS
Accumulator
Base
Count
Data
Stack Pointer
Base Pointer
Source Index
Destination Index
Instruction Pointer
Data
group
Pointer and
index group
Extra
Code
Data
Stack
Segment
group
Each register has different usage as shown in Table (1) below. The general purpose
registers can be "split". You have the AH and the AL register for example. AH contains
the high byte of AX and AL contains the low byte. You also have: BH, BL, CH, CL, DL, DH
So if for example. DX contains the value 1234h DH would be 12h and DL would be 34h.
SS Stack Segment
ES Extra Segment
Pointer Registers
IP
Instruction Pointer
SP Stack Pointer
16-bit number that points to the offset that the stack is using
BP Base Pointer
General-Purpose Registers
AX Accumulator Register
BX Base Register
CX Count Register
DX Data Register
Index Registers
SI Source Index
used by string operations as source
DI Destination Index
used by string operations as destination
Table(1): Registers of 8086 microprocessor and their purposes
And a 16-bit FLAG Register. The FLAGS Register consists of 9 status bits. These bits are
also called flags, because they can either be SET (1) or NOT SET (0). All these flags have a
name and purpose.
Abr.
Name
Description
OF
DF
IF
TF
SF
ZF
Direction Flag
Interrupt Flag
Trap Flag
Sign Flag
Zero Flag
AF
Auxiliary Carry is set when an operation produces a carryout from bit 3 to bit 4
PF
Parity Flag
CF
Carry Flag
; one operand
; two operands
Segments:
Code, Data, Stack an Extra. Within the 1 MB of memory space the 8086 defines four 64 K byte
memory blocks called the code segment, data segment, stack segment, and the extra segment.
Hello Program
1234-
click Start (All) Programs Run then write cmd and click OK.
Go to directory C:\Tasm\Bin
Type the command C:\Tasm\Bin\edit Hello.asm
A blue screen will open, write the following Hello program
Ana
lysi
s of the Hello program:
Instruction
DOSSEG
MODEL SMALL
.DATA
.CODE
@Data
mov ax, @data
mov ds, ax
Description
is a directive to tell the assembler to arrange data
segment, code segment and stack segment as DOS
arrangement.
is a directive to tell the assembler to use one data
segment and one code segment.
is a directive to put in data segment.
is a directive to put in code segment.
is a default address of data segment to put it in ax
register.
As note we can't put data in ds register directly. So
we use intermediate register (ax) as in the mov ds, ax
C:\Tasm\Bin\td Hello
Number
1
2
3
4
5
6
7
8
9
10
11
12
Description
Indicate to the menu bar of turbo debugger
Indicate to the region contain Code pane
Indicate to the region contain Register pane
Indicate to the region contain Data pane
Indicate to the region contain Flag pane
Indicate to the region contain Stack pane
Indicate to the instruction pointer (IP) it contains the offset address of the instruction will be execute.
Indicate to Code register that have value of (42CC) and we get it from register pane.
The offset address of each instruction
This statement tell the assembler to put (@data) default offset address in AX and this value from figure
equal to (42CD)
indicate to the machine language of statement and from figure it is equal to (B8CD42)
This column is the values of Registers.
Lab work:
Write the previous code, Hello To My first Assembly lab program then then Use Debugger to
single step through this program using the F7 (TRACE) command
Home work
Write an assembly language program to print all letters as follows:
AB..........YZ
Note : To print a character on the screen you have to use the int 21h with the service 2 , the
character to be printed have to be in dl . For Example,the following code print A on the screen.
mov dl, 41h
mov ah, 2
int 21h