Username:
Password:
Assembly Language Programming Tutorials

Necessary Fundamentals / Step by Step Execution

Subtitles of the Movie

Everything is done one step at a time, this is particularly true of an Assembly Language program and the steps are very small. You copy data in the location you wish and then you do something to it. There are only four places that data can be addressed in a program. You can of course address values in memory, these are usually named locations but they can also be locations that you compute or have previously stored somewhere. Some hardware has the ability to perform simple operations directly in memory but mostly the computer memory is used only of storage of values. The CPU has locations for holding data, these are called registers. In a normal course of things, values are loaded into registers and they have operations performed on them there. They will stay there until you override them. The third source of values can be inside the instruction itself, these are constants that you use in your program. For example, if you wish to load the value 10 into a register instead of declaring a variable and assigning it that value so you can go and get it later it may be easier to use an immediate value, that is, a constant value that can be part of the instruction itself. Everything happens one step at a time, exactly what steps are required depend on the capabilities of the hardware, for example to add 5 to Y you may need to perform these steps. Somewhere in memory is a location that you have tagged with a label Y. You use a copy instruction to load the value from that location into a register where you can perform addition. After this instruction has been executed, two copies of the value of the Y exist, one in memory and the one that you put in the register. Exactly what is required to do this addition will vary depending on what the hardware is capable of doing but more than likely it will be a simple instruction to add an immediate value to the register. The final step is to copy the modified value from the register back into memory. When writing a program you will need to remember which registers are left holding copies of which values so if you need them again you can skip the loading step. You will need to be familiar with the instructions for add, subtract, multiply, divide, and anything else the computer is capable of doing. You will need to know which instructions set the carry and overflow bits so you can test for errors in special conditions. You will also need to know how to perform some basic instructions and there are several different ways of doing each one. That's what an assembly language program is made of. Tiny steps. You write instructions to do basic things over and over in a planned sequence and you have a program. There are only a few basic things that can actually be done. One of them is copying data, every assembly language program copies bit patterns from one location to another. You will always find a number of instructions designed to do nothing but duplicate data. You will also find a number of instructions to modify bit patterns. Of course there are always instructions to add and subtract, you will also find instructions to and or or values to shift registers and clear and set single bits. Another task is testing bits. Many of the arithmetic operations set special flag bits that can be tested to find out about how the operation went. Programs often jump from one place to another, a lot of the jumps will require that you test one of the condition code bits first and jump according to the results, there are dozens of ways to jump, one is a Call to a function which involves storing a return address before the jump. Another is a Return from a function which finds a previously stored address and jumps to it. IO operations are important in a program, this type of operation is particularly hardware dependent. It often involved responding to external interrupts and reading and writing device ports. It can get complicated but every program does it one way or another. If no input or output is performed, why does a program run?

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