Introductive Notions

Introductive Notions
Introductions to assembly programming. The necessity of assembly programming.

Assembly (ASM) permits us to understand what really happens inside a computer. Getting used with this method of programming is very beneficial for a programmer, contributing to the efficiency of the developed programs, regardless of the programming language used.
There are many reasons why ASM programming is necessary. ASM generated code is usually very fast. Some programs or portions of programs therefore would be more efficient written this way. Also ASM provides direct access to the hardware.
Another important aspect is the program development for dedicated equipment. It doesn’t take a rocket scientist to know that a washing machine or a microwave oven can’t be running a program written in, lets say PASCAL or COBOL.

Information is manipulated by computers in the form of bits (binary digits). A binary digit can take only two values (1 & 0). The coresponding hardware model is a bitstable. A bitstable is an electronic circuit capable of storing coded values of 1’s or 0’s thus storing a bit. A group of bitstables forms a register. For example 8 bitstables form a 8 bit register. The information stored in this register can be binary coded from 00000000 (all bits = 0) to 11111111 (all bits = 1). Its easy to see that the number of combinations that can be stored are 256 (2^8). As a base rule a n bit register can store 2^n distinct combinations. This combinations are called bytes (if n = 8), words (if n = 16,32 …). The Intel compatible processors have words of 16, 32 … bits (there can be even a larger number of bits but the number has to be divideble by 8).
The computers memory is seen as a succession of bytes. Every byte has a memory offset associated with it. To access the memory there has to be a memory register, whose lenght determines the maximum memory size. If we have an 8 bit memory register then the maximum memory size is 2^8 bytes, and so on.
A special memory offset is the offset of the currently executed instruction. All processors have a special register for this purpose called the [PC](Program Counter).
A special memory zone is the so called stack. The stack is an abstract concept, but processors have special instructions for operations with this kind of data structure. A stack is characterized by a current address (called the stacks “top”), addressed thru a special register called [SP] (Stack Pointer). The stack operations are [PUSH x] (stores x on top of the stack) and [POP x] (return the value on top of the stack in x). The stack is also used for data storing. For example when a [CALL func] instruction is issued the [PC] register will point to the first instruction from the routine and the address of the instructions following the [CALL func] will be [PUSH]ed on the stack. When a [RETURN] instructions is issued from the subroutine the [PC] will point to the [POP]ed value of the stack.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top