flat assembler
Message board for the users of flat assembler.

Index > Main > I'm having trouble understanding certain instructions...

Author
Thread Post new topic Reply to topic
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 10 Dec 2006, 01:31
I'm taking more and more time to understand asm, but some instructions are vague... I'm sure i'll have trouble with others in the future, but right now i'm havin' a tough time with some of these things and i've done a little research with the search function to solve alot of the problems but some questions still remain.

Quote:
;HARDWARE STACK: Well, i guess it's now a good time to mention what the hardware stack actually is and how to calculate it.
;The stack puts things from high to low. So if the top of the stack is 399, then the first thing in the stack is 399, and the
;next thing in the stack is 398, then 397. The SS register is the top value of the hardware stack.


That's how i tried to explain the hardware stack, but other than exactly what's stated there, i don't know what it is. I'm assuming that it's a location in the RAM pointed at by the SS register. Not sure which segment it's in though. Would it be in the current segment with the rest of the program code?

then come daa and aaa... The whole concept behind them eludes me (havn't a clue what "unpacked BCD" is). I hear it has something to do with "decimals" so i'm assuming real numbers (or floats). Other than that, though, i havn't a clue what the tutorial i'm reading is talking about, nor a clue what it's trying to say in the fasm documentation.

And last but not least, xadd... Does it modify the same flags as add or none at all or what?

Thanks in advance to anyone who helps clear this up.
Post 10 Dec 2006, 01:31
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Goplat



Joined: 15 Sep 2006
Posts: 181
Goplat 10 Dec 2006, 01:56
Quote:
I'm assuming that it's a location in the RAM pointed at by the SS register. Not sure which segment it's in though. Would it be in the current segment with the rest of the program code?
SS is the stack segment, (E)SP is the pointer to the "top" of the stack. (By "top" I mean that it's the address of the most recently pushed value. Since the stack grows from high addresses to low, the "top" is actually the lowest address of the portion of the stack in use.)
Quote:
then come daa and aaa... The whole concept behind them eludes me (havn't a clue what "unpacked BCD" is). I hear it has something to do with "decimals" so i'm assuming real numbers (or floats). Other than that, though, i havn't a clue what the tutorial i'm reading is talking about, nor a clue what it's trying to say in the fasm documentation.
BCD is Binary Coded Decimal, it's a way of storing numbers so that they're easy to display. It was fairly commonly used in the past but is rarely used today.

Unpacked BCD means you store one digit in each byte, so for example, the number 15393 would be stored as 01 05 03 09 03. Packed means you store one digit in each hex nybble (two digits per byte), so 15393 would be stored as 01 53 93. AAA is used for adjusting AL after performing an addition on bytes of unpacked BCD, and DAA is used for packed BCD.
Quote:
And last but not least, xadd... Does it modify the same flags as add or none at all or what?
It sets the flags in the same way as ADD.
Post 10 Dec 2006, 01:56
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8376
Location: Kraków, Poland
Tomasz Grysztar 10 Dec 2006, 02:12
kohlrak: I recommend to get an original Intel manuals, where you can read a lot of quality first-hand information about all the instructions (volume 2 contains the instruction set reference).
Post 10 Dec 2006, 02:12
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 10 Dec 2006, 02:12
So basically, BCD is decimal numbers stored as Hex? Such as 11 would be 0x01 and 0x01 rather than 0xB? If that is true, one could use aaa and daa to convert hex to decimal and vice versa (though, in an obscure way), am i right?
Post 10 Dec 2006, 02:12
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 10 Dec 2006, 02:17
so it dosn't start the next digit until F+1 (0x10)? Not a very efficient system, in my book, but there's probably a purpose for it outside of my current views on programming. lol And thanks for the link, i bookmarked it.
Post 10 Dec 2006, 02:17
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8376
Location: Kraków, Poland
Tomasz Grysztar 10 Dec 2006, 02:17
As unpacked BCD it would be 0x01 and 0x01, as packed BCD it would be 0x11. For unpacked BCD you've got AAA and AAS, for packed BCD you've got DAA and DAS.
Post 10 Dec 2006, 02:17
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 10 Dec 2006, 02:22
So packed is essentualy what everything is by default? If that's the case everything should be in order after adding and subtracting and we shouldn't need DAA or DAS unless we're trying to use unsigned bytes rather than signed bytes.
Post 10 Dec 2006, 02:22
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
hckr83



Joined: 12 Nov 2006
Posts: 86
Location: usa
hckr83 10 Dec 2006, 02:23
Post 10 Dec 2006, 02:23
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 10 Dec 2006, 06:04
Here is a zip that has all of AMD's instruction documentation pdf's (32 and 64bit).

It's too large to upload here
http://dfmsysri.com/misc/AMD%20DOCS.zip

It cover general instructions, sse, optimization techniques, ring 0 system instructions etc.
Post 10 Dec 2006, 06:04
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.