section .bss
num: resb 3
section .text
global _start
_start:
; Read input
mov eax, 3
mov ebx, 0
mov ecx, num
mov edx, 3
int 80h
sub byte [num+2], 1
cmp byte [num+2], 255
jne skip_borrow
sub byte [num+1], 1
cmp byte [num+1], 255
jne skip_borrow
sub byte [num], 1
skip_borrow:
cmp byte [num], 0
jne skip_carry
mov byte [num+1], 9
mov byte [num+2], 9
skip_carry:
mov eax, 4
mov ebx, 1
mov ecx, num
mov edx, 3
int 80h
mov eax, 1
mov ebx, 0
int 80h
The code is reading three digit input number and one digit input number. subtracting one digit number from lower than 100 and higher than 100 works. However, subtracting from 100, 200, 300 is giving wrong output. For example, 100 minus 1 gives me 10/ not 99 or 099 and 200 minus 1 gives me 20/ not 199. How do I solve this issue.