设在内存中首地址为BLOCK的区域存有一批数据:61H,84H,93H,0C4H,17H,0FFH,52H,2AH。分别按下列要求编写汇编语言程序: (1) 视该批数据为8位无符号数,采用冒泡法将其按升序排序; (2) 视该批数据为8位有符号数,采用冒泡法将其按升序排序。
时间: 2023-02-27 09:35:03 浏览: 123
汇编语言采用冒泡法对无符号数进行排序
5星 · 资源好评率100%
(1) 无符号数排序
```
org 100h
start:
mov cx, 8
jmp sort
next:
dec cx
jz end
sort:
mov bx, cx
jmp compare
compare:
dec bx
jz next
mov ax, [BLOCK + bx]
cmp ax, [BLOCK + bx + 1]
jae compare
xchg ax, [BLOCK + bx + 1]
jmp compare
end:
ret
```
(2) 有符号数排序
```
org 100h
start:
mov cx, 8
jmp sort
next:
dec cx
jz end
sort:
mov bx, cx
jmp compare
compare:
dec bx
jz next
mov ax, [BLOCK + bx]
cmp ax, [BLOCK + bx + 1]
jge compare
xchg ax, [BLOCK + bx + 1]
jmp compare
end:
ret
```
阅读全文