Make your own free website on Tripod.com
Prev TOP NEXT HOME

Learn the architecture and instruction set

The Morse book might seem like a lot of book to buy for just two really important chapters; other books devote a lot more space to the instruction set and give you a big beautiful reference page on each instruction. And, some of the other things in the Morse book, although interesting, really aren't very vital and are covered too sketchily to be of any real help. The reason I like the Morse book is that you can just read it; it has a very conversational style, it is very lucid, it tells you what you really need to know, and a little bit more which is by way of background; because nothing really gets belabored to much, you can gracefully forget the things
you don't use. And, I very much recommend READING Morse rather than studying it. Get the big picture at this point.

Now, you want to concentrate on those things which are worth fixing in memory. After you read Morse, you should relate what you have learned to this outline.

1. You want to fix in your mind the idea of the four segment registers CODE, DATA, STACK, and EXTRA. This part is pretty easy to grasp. The 8086 and the 8088 use 20 bit addresses for memory, meaning that they can address up to 1 megabyte of memory. But, the registers and the address fields in all the instructions are no more that 16 bits long. So, how to address all of that memory? Their solution is to put together two 16 bit quantities like this:

calculation SSSS0 ---- value in the relevant segment register SHL 4
depicted in AAAA ---- apparent address from register or instruction
hexadecimal --------
RRRRR ---- real address placed on address bus

In other words, any time memory is accessed, your program will supply a sixteen bit address. Another sixteen bit address is acquired from a segment register, left shifted four bits (one nibble) and added to it to form the real address. You can control the values in the segment registers and thus access any part of memory you want. But the segment registers are specialized: one for code, one for most data accesses, one for the stack (which we'll mention again) and one "extra" one for additional data accesses.

Most people, when they first learn about this addressing scheme become obsessed with converting everything to real 20 bit addresses. After a while, though, you get use to thinking in segment/offset form. You tend to get your segment registers set up at the beginning of the program, change them as little as possible, and think just in terms of symbolic locations in your program, as with any assembly language.

EXAMPLE:
MOV AX,DATASEG
MOV DS,AX ;Set value of Data segment
ASSUME DS:DATASEG ;Tell assembler DS is usable
.......
MOV AX,PLACE ;Access storage symbolically by 16 bit address

In the above example, the assembler knows that no special issues are involved because the machine generally uses the DS register to complete a normal data reference.

If you had used ES instead of DS in the above example, the assembler would have known what to do, also. In front of the MOV instruction which accessed the location PLACE, it would have placed the ES segment prefix. This would tell the machine that ES should be used, instead of DS, to complete the address.

Some conventions make it especially easy to forget about segment registers. For example, any program of the COM type gets control with all four segment registers containing the same value. This program executes in a simplified 64K address space. You can go outside this address space if you want but you don't have to.

2. You will want to learn what other registers are available and learn their personalities: