汇编语言 2位十六进制数(字符),转换成数值保存到字节变量num(需要用逻辑左移指令或乘法指令)

来源:互联网 发布:淘宝手链店 编辑:程序博客网 时间:2024/06/07 05:23
;This is the structure of a main module using simplified segment directives
.8086
.MODEL SMALL,C
.STACK 100
.DATA
;......Place data declarations here
db "$$$$$$"
num db 0
c1 db 0
c2 db 0
db "$$$$$$"
;......


.CODE
.STARTUP
;......Place instructions here
mov ah,01h//输入第一个值
int 21h
mov dh,al

mov c1,al


mov ah,01h//输入第二个值 
int 21h
mov dl,al
mov c2,al


.if dh>='0' && dh<='9'
sub dh,'0'
.else 
sub dh,'a'
add dh,10
.endif

.if dl>='0' && dl<='9'
sub dl,'0'//因为输入的默认是字符
.else 
sub dl,'a'
add dl,10
.endif

mov cl,4
shl dh,cl//因为第一个输入的数为高位,所以我们要左移4位,那么该值就变为高位了
add dh,dl
mov num,dh
;......
.EXIT
END
0 0
原创粉丝点击