Here's the problem, I was wondering if i am right to assume that when a three-digit input is entered, i.e. 123, then the string 1 will be stored to al, 2 to ah, but i'm not sure where the 3 goes, or if ever it's plain wrong to look at the problem that way. Here's my plan, ask for 3-digit number, access the digits separately, convert to integer, manipulate the digits separately, then check if greater than 100, 175, and so so.

In my opinion you need to use 3 different variables and store each digit in a separate variable, next convert each digit to an integer, multiply the first digit by 100, the second digit by 10 and add all digits together and save to a variable to get a 3 …

I see, so it's impossible then to convert a single 3-digit input to integer?

you can convert at any length if it's in a single variable, I've been taught that using nasm when you input a 3 or more digit number in a terminal you need to store …

## All 5 Replies

In my opinion you need to use 3 different variables and store each digit in a separate variable, next convert each digit to an integer, multiply the first digit by 100, the second digit by 10 and add all digits together and save to a variable to get a 3 digit number.

With this you only need to compare one variable for the rest of the operations

I see, so it's impossible then to convert a single 3-digit input to integer? Thanks.

I see, so it's impossible then to convert a single 3-digit input to integer?

you can convert at any length if it's in a single variable, I've been taught that using nasm when you input a 3 or more digit number in a terminal you need to store the digits in separate variables for better manipulation in the program

That was really helpful. Thank you.

You don't need many buffers. You have one buffer for your input right? That is all you need. Write a conversion function (or find one on the net, but you will better yourself writing it on your own) that takes a pointer to your input buffer, and goes thourgh each character in your buffer, converts them all and returns the integer in eax.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.