Question
I need to accept user input of a three digit number and convert it to an int. This is my code so far but it
I need to accept user input of a three digit number and convert it to an int. This is my code so far but it is not working.
the program is for x86 nasm on gl server (64 bit linux)
;accept input
mov eax, 3 mov ebx, 0 mov ecx, num mov edx, 6 int 0x80
;converting three digit number:
mov eax, [num] and eax, 0xff sub eax, '0' mov ebx, 10 mul ebx mov [num], eax
mov eax, [num+1] and eax, 0xff sub eax, '0' add eax, [num] mov ebx, 10 mul ebx mov [num], eax
mov eax, [num+2] and eax, 0xff sub eax, '0' add eax, [num] mov ebx, 10 mul ebx mov [num], eax
; print to screen
mov ebx,1 mov eax,4 mov ecx, num mov edx, 6 int 0x80
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started