Chapter 5 - Strings, Procedures and Macros: From Microprocessors and Interfacing by Douglas Hall
Chapter 5 - Strings, Procedures and Macros: From Microprocessors and Interfacing by Douglas Hall
Objective
At the conclusion of this chapter you will be able to:
Use 8086 string manipulation instructions to perform a variety of
operations on a sequence of data words in the memory.
Describe how a stack is initialize and used in 8086 assembly
language program which call procedures.
Write an 8086 assembly language program which calls a near
procedure.
Write an 8086 assembly language program which calls a far
procedure.
Write, assemble, link and run a program which consists of more
than one module.
Write and use an assembler macro.
Outline
The 8086 String instructions
Moving a String
Using compare string byte to check password
Moving a String(contd.)
Definition:
You have a string of ASCII characters in successive memory
locations in data segment, and you want to move the string to
some new location in the data segment.
Moving a String(contd.)
The basic pseudo code doesnt help much in understanding how the
algorithm will be implemented.
Expanded code:
INITIALIZE SOURCE POINTER, SI
INITIALIZE DESTINATION POINTER, DI
INITIALIZE COUNTER, CX
REPEAT
COPY BYTE FROM SOURCE TO DESTINATION
INCREMENT SOURCE POINTER
INCREMENT DESTINATION POINTER
DECREMENT COUNTER
UNTIL COUNTER=0
Need:
REPEAT-UNTIL
Compare String instruction CMPS
Using
compare
string byte
to check
passwordflowchart
necessary.
Accessing Procedure
Accessing a procedure in another segment
Put mainline program in one segment and all the procedures in
different segment.
Using FAR calls the procedures can accessed as discuss above.
Accessing procedure and data in separate assembly
module
Divide the program in the series of module.
The object code files of each module can be linked together.
In the module where variables or procedures are declared, you
must use PUBLIC directive to let the linker know that it can be
accessed from other modules.
In a module which calls procedure or accesses a variable in
another module, you must use the EXTERN directive.