Assembly 如何删除'+';或'-';MASM汇编中的字符
在MASM汇编中,如果用户写入“-22”,我想检查第一个字符是否有“-”符号,然后将其删除。 如果用户写“+12”,我想检查第一个字符是否有“+”符号,然后将其删除 下面的代码不起作用。 有人能告诉我密码有什么问题吗Assembly 如何删除'+';或'-';MASM汇编中的字符,assembly,x86,visual-studio-2019,masm,signed-integer,Assembly,X86,Visual Studio 2019,Masm,Signed Integer,在MASM汇编中,如果用户写入“-22”,我想检查第一个字符是否有“-”符号,然后将其删除。 如果用户写“+12”,我想检查第一个字符是否有“+”符号,然后将其删除 下面的代码不起作用。 有人能告诉我密码有什么问题吗 insertNums: lodsb cmp ch, 43 ;I am not sure if this is the proper way of checking for a "+" je convertPos cmp
insertNums:
lodsb
cmp ch, 43 ;I am not sure if this is the proper way of checking for a "+"
je convertPos
cmp ch, 45 ;Same with this. Does this check for ASCII 45 which is "-"?
je convertNeg
continue:
cmp eax, 0
je endInsert
sub eax, 48
mov ebx, eax
mov eax, value
mov edx, 10 ;multiplies by 10
imul edx
jc tooLargeNumber ; check for carry after multiply
add eax, ebx ;add the digit to the converted value
jc tooLargeNumber ; check for carry after adding
mov value, eax ; store temporary value from eax
mov eax, 0 ; reset eax
loop insertNums
jmp endInsert
convertPos:
; this is for positive numbers
; the goal is to just drop the'+' sign and feed it back to the loop
convertNeg:
; this one is supposed to drop the '-' sign
; and once I know it is a negative number, I would have a separate procedure for ;converting the number to a negative
cmp ch,43
迈克尔,谢谢你的解释。我如何去掉“+”或“-”符号?用0替换这些字符行吗?编辑:Nvm。用0替换它们无效。这个过程只是认为插入数字已经完成,然后跳转到endInsert。只需加载下一个字符并输入数字循环,就像从数字开始一样。