实现用8086汇编语言将45H,12H,23H,55H,77H,33H,11H,8AH,3FH,1EH输出成数字的流程图
时间: 2023-06-11 18:06:58 浏览: 91
8086汇编语言
5星 · 资源好评率100%
以下是将10个16进制数输出成数字的8086汇编语言流程图:
![8086汇编语言流程图](https://i.imgur.com/8I1aZ4W.png)
其中,用到的汇编指令包括:MOV、LEA、ADD、SUB、CMP、JG、JMP、LOOP、INT 21H。具体实现细节请参考以下示例代码:
```assembly
.model small
.stack 100h
.data
msg1 db 'The decimal numbers are: $'
nums db 45H, 12H, 23H, 55H, 77H, 33H, 11H, 8AH, 3FH, 1EH
nums_len equ $-nums
.code
main proc
; set up data segment
mov ax, @data
mov ds, ax
; print message
lea dx, msg1
mov ah, 09h
int 21h
; convert and print numbers
mov cx, nums_len ; loop counter
lea si, nums ; source index
convert_loop:
mov bl, [si] ; load byte from source
add si, 1 ; increment source index
mov bh, 0 ; clear high byte of bx
mov al, bl ; move low byte to al
sub al, 30h ; convert from ASCII to decimal
cmp al, 10 ; check if digit is greater than 9
jg skip_digit ; if so, skip this digit
mov ah, 0 ; clear high byte of ax
mov bl, 10 ; move 10 to bl
mul bl ; multiply al by 10
add ah, al ; add high byte to al
mov al, bl ; move 10 to al
mul bl ; multiply al by 10
add ax, bx ; add result to ax
jmp print_digit
skip_digit:
; handle non-digit characters (e.g. letters, symbols)
mov al, 20h ; print a space
mov ah, 02h
int 21h
jmp next_digit
print_digit:
; print digit
add al, 30h ; convert from decimal to ASCII
mov ah, 02h
int 21h
next_digit:
; check if end of array has been reached
loop convert_loop
; exit program
mov ah, 4ch
int 21h
main endp
end main
```
阅读全文