In MASM Assembly, if the user writes "-22", I want to check the first character for a "-" sign and then drop it. If the user writes "+12", I want to check the first character for a "+" sign and then drop it.
The code below is not working. Could someone please let me know what is wrong with the code.
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