1

I have a trouble on checking if the overflow flag is set after the user enter a unsigned number

I tried using the JC to check the overflow flag.

Example output

Please enter an unsigned number: 99999999999999999999999
 <32-bit integer overflow>
Not unsigned or too big.
Please enter an unsigned number: 25
25

prompt_1    BYTE    "Please enter an unsigned number: ", 0
inv_msg     BYTE    "Not unsigned or too big.", 0
inv_prompt  BYTE    "Please try again: ", 0
input_1     DWORD   ?

.code
main PROC

Try_again:
    mov     edx, OFFSET prompt_1
    call    WriteString
    call    ReadInt
    jo  Invalid_
    mov input_1, eax
    call    WriteDec
    jmp Finish_

Invalid_:
    mov edx, OFFSET inv_msg
    call    WriteString
    call    Crlf
    jmp Try_again

Finish_:

It seems work but it keep showing <32-bit integer overflow>. Does it work as normal or something goes wrong? Are there any way to stop displaying <32-bit integer overflow> or is this how it's suppose to be?

1
  • 1
    Without seeing ReadInt nobody can answer. Commented Jun 4, 2019 at 0:52

1 Answer 1

2

TL;DR: It's how it's supposed to be.


If we assume that you're using Kip Irvine's library, then you can find its source code in the Lib32 (or Lib16 or Lib64) subdirectory of whatever directory you installed the Irvine library in.

So let's take a look at ReadInt procedure in Lib32\Irvine32.asm. As you can see it just reads a string and then calls another procedure called ParseInteger32 to parse the contents of that string.

ParseInteger32 has a loop L5 where it processes the digits, and if overflow is detected within that loop it will jump to label L7, from where the string " <32-bit integer overflow>" will be printed, followed by a carriage return and a linefeed.

None of these functions appear to take any parameter that controls whether that string should be printed. So if you want to avoid having the overflow string printed you'll have to modify the Irvine source code and rebuild the library.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.