用8086汇编语言程序设计一个从键盘中输入两个字符, 输出字符的ASCII码之和的程序
时间: 2023-04-05 16:03:33 浏览: 148
非常感谢您的提问。以下是用8086汇编语言编写的程序,可以实现从键盘中输入两个字符,输出它们的ASCII码之和:
```
.model small
.stack 100h
.data
msg1 db 'Please input the first character: $'
msg2 db 'Please input the second character: $'
msg3 db 'The sum of ASCII codes is: $'
char1 db ?
char2 db ?
sum db ?
.code
mov ax, @data
mov ds, ax
; input the first character
mov ah, 09h
lea dx, msg1
int 21h
mov ah, 01h
int 21h
mov char1, al
; input the second character
mov ah, 09h
lea dx, msg2
int 21h
mov ah, 01h
int 21h
mov char2, al
; calculate the sum of ASCII codes
mov al, char1
add al, char2
mov sum, al
; output the result
mov ah, 09h
lea dx, msg3
int 21h
mov ah, 02h
mov dl, sum
add dl, 30h ; convert to ASCII code
int 21h
mov ah, 4ch
int 21h
end
```
希望这个程序能够帮助您解决问题。如果您有其他问题,欢迎继续提问。
阅读全文