The MASM Forum

Miscellaneous => 16 bit DOS Programming => Topic started by: hornet07 on April 12, 2015, 01:33:14 AM

Title: 8086 registers - NOOB question
Post by: hornet07 on April 12, 2015, 01:33:14 AM
Okay, so I was going through some tutorials on 8086 Assembly, and I hit some information that seems contradicting, to me at least.

AX, the 16-bit register is made up of:
    - high-byte AH (8-15 bits)
    - low-byte AL (0-7 bits)

So AX is AH|AL.

If you assign  1234h to AX, 12h goes to AH and 34h goes to AL. So far so good. BUT, the next part just confuses me.
The tutorial went on to convert the hex into binary and represented the value like so: 0011 0100 0001 0010, which is 3412h. This shows me that 34h is in AH and 12h is in AL, which is completely opposite of what it mentions previously. Also, the least significant byte, which for some reason is 8-15 and not 0-7 (why is this?), corresponds to the highest address (1000h), while the low byte has address 1001h.

This is quite a mess in my head. Is there something I'm missing? Or maybe the tutorial really is that dumb and misleading...

In any case, can someone please provide some in-depth explanation on this issue of addresses and low/high bytes?
Title: Re: 8086 registers - NOOB question
Post by: dedndave on April 12, 2015, 01:37:39 AM
not sure how the book explained it, but....

intel stores information, low-order byte first
so, if i stored AX (1234h) in memory, and examined the bytes, i'd see
34h, 12h

it's called "little endian"

http://en.wikipedia.org/wiki/Endianness (http://en.wikipedia.org/wiki/Endianness)
Title: Re: 8086 registers - NOOB question
Post by: Gunther on April 12, 2015, 01:44:43 AM
Hi hornet07,

I think that Dave gave the right answer. Your question has to do with the Endianness. You can find some examples about it in this tutorial (http://drpaulcarter.com/pcasm/). And welcome to the forum.

Gunther
Title: Re: 8086 registers - NOOB question
Post by: hornet07 on April 12, 2015, 02:10:57 AM
Thanks for the explanation and ebook. Can you recommend one just for 16-bit? I can work with this one as well, but I'm writing programs in 8086 for homework back in college.
Title: Re: 8086 registers - NOOB question
Post by: FORTRANS on April 12, 2015, 05:37:42 AM
Hi,

       Randy Hyde's "The Art of Assembly Language Programming"
(AoA), is in its second edition, which is 32-bit.  The first edition
was 16-bit and looks to be available as a download.

http://www.plantation-productions.com/Webster/www.artofasm.com/DOS/index.html

   It is not standard in its assembly language syntax.  But the
basics of registers and math ought to be covered.

HTH,

Steve N.
Title: Re: 8086 registers - NOOB question
Post by: rrr314159 on April 12, 2015, 10:53:04 AM
@FORTRANS, I was going to recommend that myself. Here's another web site which seems to have a better format for reading it: The Art of Assembly Language Programming by Randall Hyde (https://courses.engr.illinois.edu/ece390/books/artofasm/artofasm.html).

However, note some of the chapters can be skipped: anything about the UCR  "Standard Library" is obsolete. When he starts talking about "finite state automata" and "iterators" you should probably turn the page.

Some people think the DOS info is obsolete, I don't agree, it's still a good book / tutorial.
Title: Re: 8086 registers - NOOB question
Post by: hornet07 on April 13, 2015, 12:57:45 AM
Thank you all for your help.