String 如何在汇编8086中将整数转换为字符串

String 如何在汇编8086中将整数转换为字符串,string,function,assembly,x86-16,emu8086,String,Function,Assembly,X86 16,Emu8086,我正在尝试创建一个函数,该函数获取十六进制参数和字符* 我试图将参数转换为字符串,然后将其附加到char* 这是我的代码: wordToString程序 推动bp 莫夫英国石油公司 异或 莫夫bx,10 循环1: mov-dx,0 移动ax,[bp+6] 分区bx mov[bp+6][cx],dx 呼叫print_al_chr 国泰航空公司 cmp cx,4 jle loop1 英国石油公司 波普bp ret 2 字串ENDP 主要内容: lea dx,阵列 mov ax,num1 推送dx 推

我正在尝试创建一个函数,该函数获取十六进制参数和字符*
我试图将参数转换为字符串,然后将其附加到char*

这是我的代码:

wordToString程序
推动bp
莫夫英国石油公司
异或
莫夫bx,10
循环1:
mov-dx,0
移动ax,[bp+6]
分区bx
mov[bp+6][cx],dx
呼叫print_al_chr
国泰航空公司
cmp cx,4
jle loop1
英国石油公司
波普bp
ret 2
字串ENDP
主要内容:
lea dx,阵列
mov ax,num1
推送dx
推斧
调用wordToString
参数num1是最后推送的,因此最接近堆栈上的返回地址,可在
[bp+2]
处找到。因此,您需要编写
movax,[bp+4]

此外,您还可以在循环中检索该值,因此最终将得到5个相同的分区。将其移动到循环之前,并确保除了通过
div
指令修改
AX


您在堆栈上压入了2个字,因此返回时需要删除4个字节。写入
ret4


这不是有效的指令
在开始循环之前,需要获取指向数组的指针,然后在循环中增加该值

;Before the loop
mov  di, [bp+6]
...
;Within the loop
mov  [di], dl            <<< Use DL, a byte in the range [0,9]
inc  di
...
inc  cx
cmp  cx,4 
jle  loop1               <<< Does 5 iterations because of JLE
                         <<< For 4 iterations you would use JL
;循环前
移动di,[bp+6]
...
;循环内

你忘了描述你的问题了。此外,您没有对代码进行注释,也没有使用调试器。见鬼,你甚至还没有修复语法错误。我有个问题,我需要你的帮助来修复它。我不知道我的语法错误是什么@Jester在
[bp+6][cx]
中没有寻址模式。这段代码实际上是汇编的吗?
ret 2
mov [bp+6][cx], dx
;Before the loop
mov  di, [bp+6]
...
;Within the loop
mov  [di], dl            <<< Use DL, a byte in the range [0,9]
inc  di
...
inc  cx
cmp  cx,4 
jle  loop1               <<< Does 5 iterations because of JLE
                         <<< For 4 iterations you would use JL