Как удалить символы «+» или «-» в сборке MASM - PullRequest
0 голосов
/ 15 марта 2020

В MASM Assembly, если пользователь пишет «-22», я хочу проверить первый символ на знак «-», а затем отбросить его. Если пользователь пишет «+12», я хочу проверить первый символ на знак «+», а затем удалить его.

Код ниже не работает. Может кто-нибудь, пожалуйста, дайте мне знать, что не так с кодом.

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
...