First off, I think we should start with registers. Registers are just like keywords or library functions that many compilers such as C and QBASIC use. These predefined keywords help your program function. Some of the most common are the AX, BX, CX, and DX (which are all 16 bit). I don't want to stress too much on 32 bit registers because we're going to mainly be talking about the assembly on a 8086 processor. These four are the ones that have the responsibility of holding data. AX is the accumulator. AH and AL are the accumulator high and low values of bytes, thus the H and L. AX and it's counterparts are used in input and output situations most usually.
But before we expand into any more notes on assembly, I should formally begin this tutorial by talking about some hardware associations. First of all, what is all this talk about registers and blah, blah, blah? Come on Jeannie, you're just filling my brain up with info that I still don't know the meaning behind. Okay then, so let me try and get more in depth. Think of it this way - every tiny corner inside of the microprocessor that can hold a number is a register. So assembly is very much intertwined with hardware.
BX is the base. Like AX, it has BH and BL subparts.
CX is the counter. When you do loops in assembly (explained later on) it is CX that is used. It also has CH and CL.
DX is the displacement and has DH and DL. If you haven't noticed yet, all the registers so far have had and high and low byte values accompanied with them.
Along with registers, there are also segment registers and index registers. These will be covered shortly. Let's see if we can manage to do a small example of what we've learned. Of course, don't expect this example to be anything much because you've only learned of four registers so far.
Before I move on, it's important for me to introduce the register segments. The most commonly used ones are ES for extra segment, DS for data segment, SS for stack segment, and CS for code segment. Segments will usually be paired up with index registers broken off by a colon. For example ES:DI. The index's are DI for destination index and SI for source index. BP and SP are usually associated with pointers and are matched up against stack segments. Don't flip out on me yet, I'm trying to open up some basic points so that when I put it all together it won't seem so cryptic. Segments are presented with two numbers. Try this: go into your MS DOS prompt and type in debug. Now type in d and you'll be presented with two numbers like this: 1577: 0100. Actually, you should get a list of numbers. The first number (ex - 1577) is the segment number. The second number after the colon is the offset within the segment.
Okay, wake up now! Dozing off on me already are you? I can't say that I blame you. So stop yawning, grab some caffeinated drink, and get ready for more registers!
So assembly does have other registers which you'll need to be familiarized with. Such as pointing registers which are SP (stack pointer), BP (base pointer), and IP (instruction pointer).
When using assembly, you need to understand that a bit is the tiniest data you can incorporate. You'll need to understand the translation for numbers (view the table to the left).
So let's get started already. With assembly, I don't think it would be a good idea for me to just show an example, I should most likely explain some basic concepts. Assmbly uses exponential values for a number. That's why you should have some good grounding in algebra and other mathematical studies. Remember when your teacher told you at the beginning of the year about how important math was? Well she/he wasn't kidding. And when it comes to computer programming, math is the most vital thing. But like I said, assembly treats numbers as if they were in exponential form. So let's say you have a number that's a decimal. Then the right side of the number (everything that's coming after the decimal) would be treated with any number between 0 and 9 multiplied to an increasing negative power of ten. Say what?!? Okay, let's take things slower. Numbers that are in front of the decimal point are considered to be positive, correct? Then that would mean that they would use an increasing power of ten (remember ten with exponents) multiplied to their value (which can be anything from zero to nine). I'm going to hope you understand this factor because it's painfully important with assembly.
Assembly also has the capability to use the binary numbering system. You may have heard of that evil 0 and 1 machine language of using the switches. Well guess what? Get ready to get involved in that. The binary system, unlike the above decimal system, uses the power of 2.
In assembly, there are bit patterns which are just one long string of numbers in ones and zeros. Executable programs run these bit patterns which are stored or are in memory. But assembly is way less stressful than machine language because when the coding is compiled, it converts the instructions to a way that the computer will understand (machine language), but you the human just see it as the coding you typed in. Computers have a different way of looking at things.
When using the hexidecimal code for letters, a zero must always appear first.
I don't mean to bail out on you already, but I won't be able to work on this tutorial for a while. I've been really busy, so for now, the updating of the assembly tutorial will be delayed.
This tutorial was started on Tuesday, July 21. If you'd like to contribute to this tutorial e-mail me and tell me. I will give you credit for what you write along with your banner and a review of your page(s)!