Nvis 5586A
Nvis Technologies Pvt. Ltd.
118
Program 13:
To sort a string of a no. of bytes in descending order.
Address
Opcode
Mnemonic
Comments
0400
BE 00 05
MOV SI,0500
INITIALIZE SI REG WITH MEM LOCN 0500
0403
8B 1C
MOV BX, [SI]
BX HAS THE NO OF BYTES (TO BE USED FOR SORTING)
LOCNS 0500 & 0501
0405
4B
DEC BX
DECREMENT THE NO OF BYTES BY ONE
0406
8B 0C
MOV CX [SI]
ALSO CX HAS THE NO. OF BYTES IN LOCNS 0500 AND 0501
0408
49
DEC CX
DECREMENT THE NO OF BYTES BY ONE
0409
BE 02 05
MOV SI, 0502
INITIALIZE SI REG WITH THE STARTING ADDRESS OF
STRING (HAVING DATA BYTES).
040C
8A 04
MOV AL, [SI]
MOVE THE FIRST DATA BYTE OF STRING INTO AL.
040E
46
INC SI
POINT AT THE NEXT BYTES OF THE STRING
040F
3A 04
CMP AL,[SI]
COMPARE THE TWO BYTES OF STRING.
0411
73 06
JNB 0419
IF TWO BYTES ARE IS ABOVE THAT THE EQUAL OR 1ST
BYTE SECOND BYTE BRANCH TO (1).
0413
86 04
XCHG AL, [SI]
ELSE SECOND BYTE IS LESS THAN FIRST BYTE AND SWAP
(INTERCHANGE) THE TWO BYTES.
0415
4E
DEC SI
0416
88 04
MOV [SI],AL
0418
46
INC SI
POINT AT THE NEXT LOCN OF THE STRING
0419
E2 F1 (1)
LOOP 040C
LOOP IF CX IS NOT ZERO (I.E. CONTINUE PROCESSING
TILL Z=0)
041B
4B
DEC BX
AT THIS JUNCTURE, FIRST SORTING WILL BE OVER I.E.
FIRST NO. IS LOGICALLY
041C
BE 00 05
MOV SI,0500
COMPARED WITH THE REST OF THE NOS. FOR ALL THE
NOS. MUST BE COMPARED WITH EACH OTHER
LOGICALLY, THE CORRECT SORTING, I.E. ABOVE
PROCESSING SHOULD BE CARRIED OUT NO. OF BYTES
TIMES.
041F
75 E5
JNE 0406
0421
F4
HLT
HALT.
Note:
Press F7 button of keyboard (connected to techbook) and then press D, enter address
(from where data is to be entered), press enter and start feeding data.
For Example
After Execution
0500 :
05
0502 :
28
0501 :
00
0503 :
25
Summary of Contents for 5586A
Page 2: ...Nvis 5586A Nvis Technologies Pvt Ltd 2...
Page 23: ...Nvis 5586A Nvis Technologies Pvt Ltd 23 Memory Read Timing in Maximum Mode...
Page 30: ...Nvis 5586A Nvis Technologies Pvt Ltd 30...
Page 48: ...Nvis 5586A Nvis Technologies Pvt Ltd 48 Diagram of module RESET power Instruction Set Note...