Information Technology Reference
In-Depth Information
POP ES ;Make ES ΒΌ DS (See Table)
CLD ;Set auto-increment mode
REPNE SCASW ;Scan LIST for value in AX if not
found; increment SI by 2,
decrement CX and if; not zero
scan next location in LIST.
;If occurrence found Zero flag
is set
JNZ Not_Found ;If value not branch to
Not_Found?
MOV FLAG, 1
;Yes
SUB SI, BX
PUSH SI
;Save position
Not_Found: PUSH TEMP
;Restore IP
RET
SEARCH ENDP
It should be noted in the above example that when a call to a procedure is
initiated, the IP register is the last value to be pushed on top of the stack. Therefore,
care should be made to avoid altering the value of the IP register. The top of the
stack is thus saved to a temporary variable TEMP at procedure entry and restored
before exit.
3.6. SUMMARY
A machine language is a collection of the machine instructions represented in 0s and
1s. Assembly language provides easier to use symbolic representation, in which an
alphanumeric equivalent to machine language is used. There is a one-to-one corre-
spondence between assembly language statements and machine instructions. An
assembler is a program that accepts a symbolic language program (source program)
and produces its machine language equivalent (target program). Although assembly
language programming is difficult compared to programming in high-level
languages, it is still important to learn assembly. In some applications, small por-
tions of a program that are heavily used may need to be written in assembly
language. Programming in assembly can result in machine code that is smaller
and faster than that generated by a compiler of a high-level language. Assembly pro-
grammers have access to all the hardware features of the target machine that might
not be accessible to high-level language programmers. In addition, learning assem-
bly languages can be of great help in understanding the low level details of computer
organization and architecture. In this chapter we provided a general overview of
assembly language and its programming. The programmer view of the X86 Intel
microprocessor family of processors was also introduced as a real-world example.
Examples were then presented showing how to use the X86 instruction set in writing
sample programs similar to those presented in Chapter 2.
Search WWH ::




Custom Search