Username:
Password:
Assembly Language Programming Tutorials

The Computer / Modes & Interrupts

Subtitles of the Movie

I need to define some terms that have to do with addressing. You know the word byte it's 8 bits. It's the smallest addressable unit on the computer. That is, when a computer address is specified it is the unique address of 1 byte. Adding 1 to the address moves it to the next byte. The next sized item is called Word. A Word is in 2 bytes Ð 16 bits. To move an address from one Word to another, it is necessary to add 2 to the address. You'll find that a lot of the instructions operate on Words, which mean they operate on 16 bits as if they were a single unit. Next comes the Double Word, often written as Dword, and it's 4 bytes Ð 32 bits. To move an address from one double word to the next, add 4. The next step up is the Quad Word. It's 8 bytes long, or 64 bits. This is about as long a single data item as you'll encounter. It's common to work with integers this long and some of the longer floating point formats are 64 bits long, but the hardware doesn't stop there. The next size is 10 bytes. Now, this one doesn't come up that often, but it does happen. Next is a Paragraph, which is 16 bytes. It has a special hardware meaning I'll tell you about in a minute. The next boundary is called a Page, which is 256 bytes and is used for things like buffering and IO operations. And, finally we come to the Segment, which is 65,535 bytes, the actual number of bytes in 64K. You can declare any 64K block of memory to be a segment, but the segment must begin on the same boundary as a paragraph. That is, the address of the start of a segment must be a multiple of 16. In working with Assembly Language, you'll come across these sizes and boundaries quite often so you need to know them. For example, some instructions are designed to work with a double word and to understand it you'll need to know that a double word is 32 bits. And the computer can be operated in different modes. The mode determines how much memory can be addressed and where that memory is located. In Real Mode it's only possible to address 64K of memory at any one time. The Flat Model uses 16-bit addressing, so it can only address 64K of memory. The Segmented Memory Model makes it possible for the CPU to address a total memory space of 1 megabyte, but it uses a 16-bit address so that you only get to a 64K chunk of that 1 megabyte at any one time. Such a chunk is called a Segment. Addressing is done with two 16-bit Registers. One of them is the Base Register. It holds the address of the beginning of the 64K Segment, the other one holds the offset from the beginning of the Segment to the byte being addressed. This is the type of addressing used by DOS and Windows before NT. Using this type of addressing is ugly. You have to keep track of some strange things and remember some strange rules. The Protected Flat Model is the flat 32-bit address space that has become used almost universally these days. It is set up and controlled by the Operating System, usually Linux or Windows. The programs can then use the full 32-bit address space. The space addressed by one program goes from an address of zero to 4 gigabytes. The Segment Registers are still there, but an application program can't mess with them. They're set by the Operating System. These Segment Registers have a new job. They prevent your program from diddling with things that they shouldn't; that's the protected part. The protected area may be within your 4 gigabytes of space but if you try to access it you will get an error. When a program executes it moves through a set of instructions one at a time executing each one in turn. It may encounter an instruction that jumps to another location, but that's just a matter of the program selecting a different next instruction. But there is one important exception to this flow: the interrupt. At any time during the execution of a program an outside stimulus can cause the normal flow of a program to be interrupted. When this happens the program stops doing whatever it was doing. This usually happens right in the middle of something, it doesn't matter. The values in the registers are carefully preserved. The address of the next instruction to be executed is also saved. A special routine is called to handle the interrupt. It's normally some form of input or output. For example, the user could have pressed a key on the keyboard. It's important that the program service the interrupt by reading the identity of the key before another keystroke overwrites that in the port. Once done, the interrupt routine turns control back to the main program. Everything picks up where it left off and things continue as if nothing had happened. Then the program, at its leisure, can take a look at whatever input or output may have occurred and act accordingly. I'll be showing you specific examples of how this works in later lessons.

Tutorial Information

Course: Assembly Language Programming
Author: Arthur Griffith
SKU: 33995
ISBN: 1-935320-44-0
Release Date: 2009-05-28
Duration: 5.5 hrs / 70 lessons
Work Files: Yes
Captions: Available on CD and Online University
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 81,350 Video Tutorials (20,800 free)
  • Video Available as Flash or QuickTime
  • Over 782 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available