注册 登录
编程论坛 汇编论坛

完成程序段(转换为对应的ASCII)

hyfeng 发布于 2004-12-13 22:41, 788 次点击

 下面程序段的功能是把DA1数据区的数转换为对应的ASCII码。试完善成本程序。

DA1 DB 00H,01H,02H,03H,04H,05H,06H,07H,08H,09H

ASCI DB  10DUP(?)

    CUNT=ASCI-DAI

    LEA SI,DAI

    LEA DI,ASCI

  ————————————

LOOP:MOV AL,[SI]

  ——————————————

MOV [DI],AL

INC DI

LOOP LOOP1

2 回复
#2
meng1361382006-05-19 23:34
LOOP1 这个去那里找啊!!
#3
公子吕2006-05-20 11:40
integer数转ascii串子程序。
调用前将数字放在ax中,存放转换后字符串的地址放bx,然后将bx,ax先后压入堆栈。过程如下:

itoaproc proc near
push bp
mov bp,sp
push ax
push bx
push cx
push dx
push di
pushf

mov ax,[bp+6]
mov di,[bp+4]

ifSpecial:
cmp ax,8000h
jne EndIfSpecial
mov BYTE PTR [di],'-'
mov BYTE PTR [di+1],'3'
mov BYTE PTR [di+2],'2'
mov BYTE PTR [di+3],'7'
mov BYTE PTR [di+4],'6'
mov BYTE PTR [di+5],'8'
jmp ExitIToA
EndIfSpecial:

mov dx, ax

mov al,' '
mov cx,5 ; first five
cld ; bytes of
rep stosb ; destination field

mov ax, dx ; copy source number
mov cl,' ' ; default sign (blank for +)
IfNeg: cmp ax,0 ; check sign of number
jge EndIfNeg ; skip if not negative
mov cl,'-' ; sign for negative number
neg ax ; number in AX now >= 0
EndIfNeg:

mov bx,10 ; divisor

WhileMore: mov dx,0 ; extend number to doubleword
div bx ; divide by 10
add dl,30h ; convert remainder to character
mov [di],dl ; put character in string
dec di ; move forward to next position
cmp ax,0 ; check quotient
jnz WhileMore ; continue if quotient not zero

mov [di],cl ; insert blank or "-" for sign

ExitIToA: popf ; restore flags and registers
pop di
pop dx
pop cx
pop bx
pop ax
pop bp
ret 3 ;exit, discarding parameters
itoaproc ENDP

1