Assembly Language Programming is a method of creating instructions that are the symbolic equivalent of machine code. Thus, an assembler is a program that accepts the source code (.s19) as an input file and produces the 1s and 0s that are to be placed in the memory of the computer - this is called the machine code. There is a one to one correspondence between the assembly instructions and the machine code in memory.
An assembly language program is divided into four sections that contain the main program components:
These instructions are provided by the user.
They define data and symbols, allocate data storage locations, specify output format
200D B7 02 02 14 STAA k ;store value in k location
2010 15 END
DISCUSS the above program.
Now, let us discuss some directives:
Directives: Assembler directives are important part of an assembler program. They can define the program’s location in memory, they allow us to define symbols and contents of memory locations.
Let us visit some of the directives:
- ORG sets the value of the location counter and thus it tells the assembler where to put the next byte it generates after the ORG directive. The syntax is as follows:
ORG < expression>
Will place the opcode byte for the instruction LDAB #$EE at location $2000.
RMB (Reserve Memory Byte) reserves a block of memory whose size is specified by the number that follows the directive. The syntax is:
BUFFER RMB 80
allocates 80 decimal bytes for some data. The programmer can refer to it using the label BUFFER.
Suppose we want to load the first byte in BUFFER into accumulator A we do:
To load the 8th byte we do:
LDAA BUFFER + 7
Also, we can use the directive ORG to specify where the block of memory be reserved:
BUFFER RMB 80
this will cause a block of 80 bytes be reserved at the starting address of $100.