Assembly 32位汇编中的排序和更改值
下面我编写了一个代码,可以比较字符,将字母移动到litere数组,将数字移动到numere数组。问题是,当我试图使用printf打印字母数组时,它实际上没有打印任何内容。我想我在将包含所有字符的数组中的值移动到另一个数组时犯了一个错误,但我不确定Assembly 32位汇编中的排序和更改值,assembly,x86,32-bit,ollydbg,Assembly,X86,32 Bit,Ollydbg,下面我编写了一个代码,可以比较字符,将字母移动到litere数组,将数字移动到numere数组。问题是,当我试图使用printf打印字母数组时,它实际上没有打印任何内容。我想我在将包含所有字符的数组中的值移动到另一个数组时犯了一个错误,但我不确定 litere times 255 db 0 numere times 255 db '?' mov ESI,0 ;index of the full array of characters from t
litere times 255 db 0
numere times 255 db '?'
mov ESI,0 ;index of the full array of characters from text file
mov EDI,0 ;index of numbers array
mov EBX,0 ;index of letters array
mov ECX,[numar_caractere_citite] ;the number of all numbers and letters from the original array
repeta:
push ECX
mov DL,byte[continut_fisier+esi]
cmp DL,"0"
jl cmp_litere
cmp DL,"9"
jg cmp_litere ;if EDX>=0 && EDX <= 9 --> we found a number
jmp found_cifra
cmp_litere:
cmp DL, "A" ; compare EDX with "A"
jl continua ; jump to next character if less
cmp DL, "Z" ; compare EDX with "Z"
jle found_letter ; if EDX is >= "A" && <= "Z" -> found a letter
cmp DL, "a" ; compare EDX with "a"
jl continua ; jump to next character if less (since it's between "Z" & "a")
cmp DL, "z" ; compare EDX with "z"
jg continua ; above "Z" -> not a character
found_letter:
mov [litere+EBX],byte DL
inc EBX
jmp continua
found_cifra :
mov [numere+EDI],byte DL
inc EDI
continua:inc ESI
pop ECX
loop repeta
==>>更新每个字符是1字节,您应该存储1字节而不是4字节。那不是你的问题。您没有显示如何尝试打印,也没有说明
nume
打印是否正确。使用调试器验证数组内容,然后您就知道在哪里查找问题。您是否将ebx
写入dim\u sir\u litere
某个位置?请邮寄。如果我把代码完成成可以运行的代码,代码就可以了。是的,完整的代码就很好了。你可以用%c
打印它们,和字母一样。正如你所说,它们是ascii码。是的,你是对的。非常感谢你的时间,我真的不知道我会做什么哈哈。非常感谢。
mov ECX,[dim_sir_litere] ;number of letters from litere array
mov ESI,0
afisare_litere:
push ECX
mov AL, byte [litere+ESI]
cbw
cwde
push dword EAX
push dword format_caracter ;format is %c
call [printf]
add ESP, 4*2
inc ESI
pop ECX
loop afisare_litere
mov [dim_sir_litere], EBX ;the length of letters array
mov EBX,[dim_sir_litere] ;number of letters from litere array
mov ESI,litere
afisare_litere:
lodsb
push dword EAX
push dword format_caracter ;format is %c
call [printf]
add ESP, 4*2
sub EBX,1
cmp EBX,0
jne afisare_litere