Assembly - Language Lecture No 01 - A
Assembly - Language Lecture No 01 - A
Assistant Professor
Hajvery University (HU)
How to Install Assembly Language (MASM, Linker, Edit)
1. Download DosBox from www.getintopc.com
2. Also download with Assembly Language DOSBox
programologysoftwares.blogspot.com
Step No: 1
Step No: 2
Step No: 3
Assembly Language
Assembly Language is a specific set of instructions for a particular
computer system. It provides a direct correspondence between
symbolic statements and machine language. An Assembler is a
program written in assembly language into machine language,
which may in turn be executed by the computer. Each type of
computer has a different assembly language, because the
computer’s design influences the instructions it can execute.
Machine Instructions:
A machine instruction is a binary code that has special meaning
for a computer’s CPU – it tells the CPU to perform a task. The task
might be to move a number from one location to another, compare
two numbers, or add two numbers. Each machine instruction is
precisely defined when the CPU is constructed and it is specific to
that type of CPU. The following list shows a few sample machine
instruction for the IBM-PC:
00000100 Add a number to the AL register.
10000001 Add a number to a variable.
1 0 1 0 0 0 1 1 Move the AX register to another
register.
The instruction set is the entire body of machine instructions
available for a single CPU, determined by its manufacturer.
Registers
Registers are high-speed storage locations inside the CPU which
are used by nearly every instruction. They are identified by two-
letter names, such as AH, AL AX and so on.
Mnemonic
A mnemonic (pronounced ni-man-ik) is a short alphabetic
code that literally “assists the memory” in remembering a CPU
instruction. It may be an instruction or a directive. An example of
an instruction is MOV (move). An example of an assembler
directive is DB (define byte), used to create memory variable.
Operand.
An instruction may contains zero, one, or two operands. An
operand may be a register, a memory variable, or an immediate
value: for Example
10 (immediate value or constant)
count ( m e m o r y v a r i a b l e )
AX (Register)
The choice of operand is usually determined by the addressing
mode. The addressing mode tells the assembler where to find the
data in each operand: in a register, in memory, or as immediate
data. Example
AX 16 bits Register
AH Register AL Register
CPU Registers
AX Accumulator: It is favored by the CPU for arithmetic operations.
DX Data: The DX Register has a special role in multiply and divide operations.
CS Code Segment: The CS register holds the base location of all executable instruction (code) in a program.
DS Data Segment: The DS register is the default base location for memory variables.
SS Stack Segment: The SS register contains the base location for the current program stack.
ES Extra Segment: The ES register is an additional base location for memory variables.
SI Source Index: This register takes its name from 8088’s string movement instructions, where the source
string is pointed to by the SI register.
DI Destination Index: The DI register acts as the destination for the 8088’s string movement instructions.
IP Instruction Pointer: The IP register always contains the location of the next instruction to be executed.
SP Stack Pointer: The SP register contains the offset, or distance from the beginning of the stack segment to
the top of the stack. The SS and SP registers combine to form the complete top-of-stack address.
Flags Registers x x x x O D I T S Z x A x P x C
The flags register is a special 16-bit register with individual bit positions assigned to show the
status of the CPU or the results of arithmetic operations. Each relevant bit position is given a name;
other positions are undefined:
Assemble and Test the Program
You have DEBUG available, you can assemble and test our sample
program. You will find a debugger to be the perfect tool for
learning how assembler instruction work. It prompt for
commands using the hyphen(-) character. The DEBUG commands
to assemble and test the program are as follows:
C:\>DEBUG
-A 100 (Begin Assembly at location 100)
mov ax, 5 (Enter the rest of the program)
add ax, 10
add ax, 20
mov [0120], ax
int 20
-
-R (Display the Register)
-T (Trace each instruction)
-T
-T
-G (Execute the rest of the program)
-Q (quit DEBUG, and Return to DOS)
DEBUG commands:
A 100 Assemble instruction into machine language, beginning at
location 100
G Go(execute) from the current location to the end of the program.
P Procedure trace a single instruction or DOS function call.
Q Quit DEBUG and return to DOS
R Register display only.
T Trace a single instruction, and show the contents of the registers
after it is executed.
U Un-assemble, Disassemble memory into assemble language
instructions.
Assignments
Display the outputs
mov ah, 7f Display the outputs
mov ax, 1234 mov al, fffe
mov bh, al mov al, 2
mov bl, ah mov bl, 8c
int 20 mov bh, 2d
Display the outputs mov bx, ax
mov ax, 0 int 20
dec ax
dec ax
add ax, 2
inc ax
int 20
The IBM-PC/XT/AT Memory Map
00000 Interrupt Vector Table
00400 BIOS and DOS Data
00600 Resident portion of DOS
640K
User RAM