设在内存中首地址为BLOCK的区域存有一批数据:61H,84H,93H,0C4H,17H,0FFH,52H,2AH。分别按下列要求编写汇编语言程序: (1) 视该批数据为8位无符号数,采用冒泡法将其按升序排序; (2) 视该批数据为8位有符号数,采用冒泡法将其按升序排序。
时间: 2023-02-27 10:35:02 浏览: 115
(1) 冒泡排序(8位无符号数):
```
MOV CX, 8
LEA SI, BLOCK
AGAIN:
MOV BX, CX
DEC BX
LEA DI, BLOCK
NEXT:
MOV AL, [SI]
CMP AL, [SI+BX]
JAE SKIP
XCHG AL, [SI+BX]
MOV [SI], AL
SKIP:
ADD SI, 1
LOOP NEXT
DEC CX
JNZ AGAIN
```
(2) 冒泡排序(8位有符号数):
```
MOV CX, 8
LEA SI, BLOCK
AGAIN:
MOV BX, CX
DEC BX
LEA DI, BLOCK
NEXT:
MOV AL, [SI]
CBW
CMP AX, [SI+BX]
JAE SKIP
XCHG AL, [SI+BX]
MOV [SI], AL
SKIP:
ADD SI, 1
LOOP NEXT
DEC CX
JNZ AGAIN
```
阅读全文