Information Technology Reference
In-Depth Information
TABLE 3.13 Sample of the X86 Processor Control Instructions
Mnemonic
Operation
Subtype
HLT
Halt
External sync
LOCK
Lock the bus
External sync
CLC
Clear carry flag
Flag
CLI
Clear interrupt flag
Flag
STI
Set interrupt flag
Flag
INVD
Invalidate data cache
General control
defined as an array of N elements each of size byte. FLAG is a memory variable used
to indicate whether the list has been sorted or not. The register CX is used as a coun-
ter with the Loop instruction. The Loop instruction decrements the CX register and
branch if the result is not zero. The addressing mode used to access the array List
[BX þ
1] is called based addressing mode. It should be noted that since we are
using BX and BX
þ
1 the CX counter is loaded with the value 999 in order not to
exceed the list.
MOV CX, 1000 2 1 ; Counter ¼ CX (1000 2 1)
MOV BX, Offset LIST ; BX pointer to LIST
CALL SORT
.....
SORT PROC NEAR
Again: MOV FLAG, 0
; FLAG 0
Next:
MOV AL, [BX]
CMP AL, [BX þ 1] ;Compare current and next values
JLE Skip ;Branch if current , next values
XCHG AL, [BX þ 1] ;If not, Swap the contents of the
MOV [BX þ 1], AL
;current location with the next one
MOV FLAG, 1
;Indicate the swap
Skip:
INC BX
; BX BX þ 1
LOOP Next
;Go to next value
CMP FLAG, 1
;Was there any swap
JE Again
;If yes Repeat process
RET
SORT ENDP
Example 4
Here we implement the SEARCH algorithm in the 8086 instruction
set. LIST is defined as an array of N elements each of size word. FLAG is a
memory variable used to indicate whether the list has been sorted or not. The register
CX is used as a counter with the loop instruction. The Loop instruction decrements
Search WWH ::




Custom Search