试用8086汇编语言编程,把ASCII表示的两位十进制数,转换成二进制数的子程序

试用8086汇编语言编程,把ASCII表示的两位十进制数,转换成二进制数的子程序,第1张

ascII to binary

data segment

a1  db '87'

len dw $-a1

b1  dw 0

data ends

code segment

assume cs:code, ds:data

start:

mov ax,data

mov ds,ax

lea si,a1

lea di,b1

mov cx,len

call asc2bin

mov ax,4c00h

int 21h

si-source ascii string

di-binary's variable

cx-ascii's length

asc2bin proc near

    mov bl, 10

L0:

mov ax, [di]

mul bl

mov dl, [si]

and dl, 0Fh

add al, dl 

adc ah,0

mov [di],ax

inc si

loop L0

ret

asc2bin endp

code ends

end start

延时时间和你设的频率有关,这里把PUSH AX POP AX循环100次,在乘以循环周期就是延时时间,至于用AX,BX无关紧要,只要最后恢复现场就好。

当然没问题,++——一样可以,NoP也没问题,LOOP也算时间


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/7781031.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-09
下一篇 2023-04-09

发表评论

登录后才能评论

评论列表(0条)

保存