Professional Documents
Culture Documents
Final Lecture Chapter 3 Part 2 3 Additional Notes For Assembly Language
Final Lecture Chapter 3 Part 2 3 Additional Notes For Assembly Language
Part 2 - 3
Presented by : Amanuel G
Steps involved in Programming
2
input/output
decision
Advanced Instruction :
General approach With MOVS instruction
MOV SI, 1000H MOV SI, 1000H
MOV DI, 2000H MOV DI, 2000H
MOV CX, 0020H MOV CX, 0002H
BACK : MOV AX, [SI] CLD
MOV [DI], AX REP MOVSB
INC SI
INC DI
DEC CX
JNZ BACK
In the real time applications, such as traffic light control, digital clock,
process control, serial communication, it is important to keep a track with
time.
These time delays are in few seconds and can be generated with the help
of executing group of instructions number of times. This software timers are
also called time delays or software delays.
In this program one or more external loop is added to execute the internal
loop multiple times. So that we can get larger delays.
Example 4
Write an 8086 ALP to generate a delay of 1 minute if 8086 system frequency is 10MHZ.
DUB : This directive is used to initialize several locations and to assign values to these locations.
Format: Name Data_Type Num DUP (value)
Example:
TABLE DW 10 DUP(0) ; reserve an array of 10 words of memory and initialize all 10 words
; with 0. array is named TABLE
END : this directive is put after the last statement of a program to tell the assembler that this is the
end of the program module. The assembler ignores any statement after an END directive.
EQU : this directive is used to redefine a data name or variable with another data name, variable,
or immediate value. The directive should be defined in a program before it is referenced.
Formats:
Numeric Equate : name EQU expression
String Equate : name EQU <string>
EVEN : tells the assembler to advance its location counter if necessary so that the next
defined data item or label is aligned on an even storage boundary. This feature
makes processing more efficient on processors that access 16 or 32 bits at a time.
Example :
EVEN LOOKUP DW 10 DUP (0) ; declares the array of ten words starting from even address.
EXTRN : is used to inform assembler that the names or labels following the directive
are in some other assembly module. Names and labels referred to as external in one
module must be declared public.
GROUP : a program may contain several segments of the same type (code, data, or
stack). This directive is used to collect them all under one name, so that they reside
within one segment, usually a data segment.
Format: Name GROUP seg_name,… , seg_name
LENGTH: an operator which tells the assembler to determine the number of elements
in some named data item such as a string or array.
Example:
MOV BX, LENGTH STING1 ;loads the length of string in BX.
MACRO: used to define macros in programs.
ENDM: used along with the MACRO directive to define the end of the macro.
16
Model Code Segments Data Segments
small one one
medium multiple one
compact one multiple
large multiple multiple
NAME : is used at the start of a source program to give specific names to each assembly
module.
OFFSET : it is an operator which tells the assembler to determine the offset or displacement
of a named data item (variable) from the start of the segment which contains it.
Example:
MOV AX, OFFSET MES1 ; loads the offset of variable, MES1 in AX register.
ORG : the assembler uses a location counter to account for its relative position in a data or
code segment.
Format : ORG expression
Example : ORG 1000H ; set the location counter to 1000H
Example :
CODE SEGMENT
…
CODE ENDS
Variable: is an identifier that is associated with the first byte of data item.
Example:
array DB 10, 20, 30, 40, 50 ; here, array is a variable which is associated with the first byte of the
; data item. i.e. 10
Suffix : in assembly language programming base of a number is indicated by a suffix as follows,
B – binary O - octal
D – decimal H - hexadecimal
File1.asm File2.asm
EXTRN ROUTINE: FAR PUBLIC ROUTINE PROC
FAR
…
ROUTINE ENDP
The part located in ROM is referred to as ROM-BIOS. The other part which is loaded in
RAM during power-up from hard disk or floppy disk is known as DOS.
BIOS is located in an 8K-byte ROM at the top of memory, the address range being from
FE000H to FFFFFH.
The ROM-BIOS contains routines for power-on self test, system configuration analysis,
time of day, print screen, bootstrap loader, i/o support program for asynchronous
communication, keyboard, diskette, printer and display.
There are some extremely useful subroutines within BIOS and DOS that are available to
the user through the INT (interrupt) instruction.
The INT instruction is somewhat like a FAR call. When it is invoked, it saves CS:IP and
the flags on the stack and goes to the subroutine associated with that interrupt.
INT xx ; the interrupt number xx can be 00 – FFH
Before the service of INT is requested, certain registers must have specific values in
them, depending on the function being requested.
Prepared by : Amanuel G ECE DEPARTEMENT
INT 21H option 02: outputting a single character to the monitor
29