News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Watching negative numbers?

Started by Nate523, September 20, 2024, 04:20:26 AM

Previous topic - Next topic

Nate523

#15
Quote from: kkurkiewicz on September 26, 2024, 03:32:23 AMThe VS debugger allows you to observe any valid expression.
If the type of the register ends up being recognized as "unsigned short", try casting it to "short", i.e. change "CL" to "(short) CL".

Hey thanks! The CL register is doing what it does, didn't change the value, but if I put '(short)' before the RCX register in the watch window, the magical -50 shows up! So that's useful, guess '(long)' or other will need to be used depending on the size of the value, but I like seeing the actual value in the watch window  :thumbsup: 
 
You cannot view this attachment.

kkurkiewicz

#16
CL is 206 because NEG generates a borrow (note that 206 = 162 - 50).
I don't know if there is any way to customize this, but a borrow should be indicated by an upwards arrow following the value, at least in VS 2019:


Kamil

NoCforMe

By "borrow" you mean the sign bit set, yes? Borrow would be a value in the flags register, hence evanescent (disappearing).
Assembly language programming should be fun. That's why I do it.

kkurkiewicz

A borrow as in subtraction with borrow.
NEG is equivalent to subtracting the operand from 0, not "flip and add one".
Kamil

iZ!

Quote from: kkurkiewicz on September 26, 2024, 04:57:50 PMsubtraction with borrow
= arg1 - arg2 - Carry flag

Quote from: kkurkiewicz on September 26, 2024, 04:57:50 PMNEG is equivalent to subtracting the operand from 0, not "flip and add one".
"flip and add one" works if "flip" is the NOT operator

zedd151

:azn:

kkurkiewicz

Quote from: kkurkiewicz on September 26, 2024, 07:52:49 AMCL is 206 because NEG generates a borrow (note that 206 = 162 - 50).
I don't know if there is any way to customize this, but a borrow should be indicated by an upwards arrow following the value...

Sorry, this is just completely wrong.

CL is 206 because that is precisely what is stored in the last byte of the register after it is set to 50 and negated. And regarding the arrow—that is not an arrow but the Latin capital letter I with circumflex, code point U+00CE. (When the type of the watched value is char, the character is simply displayed next to the numeric value.)
Kamil

NoCforMe

Yes; hopefully not to belabor the point, and to reduce confusion on the OP's part:
Yes, CL shows 206 because that is the unsigned value of that low (8-bit) part of the RCX register.
If it were displayed as a signed value it would show -50 instead.
The sign (and therefore the presence of that weird up-arrow-looking character) depends on the sign bit of the value, not a "borrow". (Borrow is something that happens during a subtraction operation; here we're just displaying values in registers.)

Does that make sense?
Assembly language programming should be fun. That's why I do it.

kkurkiewicz

The weird up-arrow-looking character indicates neither a carry nor a borrow.
Change the value to 65, and the arrow will change into 'A'.
Kamil

iZ!

Quote from: zedd151 on September 27, 2024, 04:42:17 AM
Quote from: i Z ! on September 26, 2024, 09:16:47 PMarg1 - arg2 - Carry flag
And what is the state of the sign flag?
it gets set according to the result, after the operation. Has no effect what state it's in afaik..
I only wanted to point out that there's no "borrow flag" generated by NEG instruction

NoCforMe

Quote from: kkurkiewicz on September 27, 2024, 05:36:44 AMThe weird up-arrow-looking character indicates neither a carry nor a borrow.
Change the value to 65, and the arrow will change into 'A'.

So what exactly does that sign (the up-arrow/circumflex) mean?
Assembly language programming should be fun. That's why I do it.

kkurkiewicz

If the numeric value shown in the Watch window corresponds to a printable character, the character is simply displayed next to the value for your convenience so that you do not have to look it up in any conversion chart.
Kamil

NoCforMe

That's a nice li'l feature, one that every debugger should have.
My only nitpick is that I would've put those characters in quotation marks to indicate that they're a character.
Assembly language programming should be fun. That's why I do it.