Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8866393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:46:23+00:00 2026-06-14T16:46:23+00:00

So if I wanted to add two unsigned ints I would simply write dat1

  • 0

So if I wanted to add two unsigned ints I would simply write

dat1 db ff
dat2 db ff
res dw ?

and in the code segment:

mov ax, dat1
add ax, dat2
mov dl,0
adc dl,0 ;initialize the contents of dl and use it to store the carry flag
mov byte ptr res, ax
mov byte ptr res+1, dl

BUT, what would the code look like if I wanted to add two SIGNED integers? Can I somehow access the sign flag?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:46:25+00:00Added an answer on June 14, 2026 at 4:46 pm

    First the errors:

    • It reads 16 bits from variables that allocate only 8 bits.
    • It doesn’t make sense to write to address res+1 either (but to res+2).
    • also trying to write mov byte ptr addr, ax should fail
      • should be mov word ptr res, ax

    Answer to the first question is: nothing special.
    add ax, bx doesn’t care if they are signed or not. The fun part comes when inspecting the status register. There you have the carry flag, sign flag and overflow flag. (and 25+ unrelated flags). As a side note: overflow flag is set, if carry_flag != sign_flag for addends of the same sign. It means that addition/subtraction of two negative numbers can be interpreted positive or adding two positive numbers can be interpreted as negative. For addends of different sign (3) + (-2) overflow doesn’t happen.

    Sign flag can be accessed by comparing and branching:

    add ax,bx  
    jns process_unsigned   // or
    js process_signed  
    

    Or if you are concerned to transfer the sign bit of a register somewhere else, you can
    – mov cl, 16; sar ax, cl; // shift the sign bit over the word ax or
    – add ax, ax (or shl ax,1) // shift the sign bit out of the “left” side of AX to Carry Bit

    Additionally one can pushf status flag, pop ax it to a general purpose register, and inspect any individual bits.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I wanted to add two natural numbers together that are more then 150
I wanted to add a method to two models, so I made a module
How it started? I wanted to add two columns, that are not in business
For a silly bbcode parser I wanted to add two definitions into one, my
I am building PB messages containing 4 int32 fields. I wanted to add two
I have two similar classes, that simply have a string name. I wanted to
If I wanted to add a column that could only be two values, for
I wanted to add crash reporting capabilities to my iPhone app. Kind of the
I wanted to add a new property to one of my model (table). Basically
I wanted to add a StackOverflow-style tag input to a blog model of mine.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.