kalpana
New User
Joined: 19 Nov 2004 Posts: 24 Location: Banglore
|
|
|
|
I will explain simple Program
For adding two numbers
here is the code
NAME OPERATION OPERND FIELD
SAMPLE START 0
BALR 12,0
USING *,12
L 3,A1
A 3,A2
ST 3,RESULT
A1 DC F'10'
A2 DC F'20'
RESULT DS F
BR 14
END
This is a simple assembler code which adds two numbers and place the result in result variable.
Every assembler program should start with START command and ends with END command. In assembly language we will perform all operations uding registers tottaly 16 register we will use.
In assembler coding we have to establish addersabilty of the program. This can be achieved by using two instructions ie; BALR and Using
BALR is RR instruction in which the next sequential instruction vale will stired in the first operand. In this sample next sequential instruction value will be stored in 12 register and the secon opernad specifies the place where u want to branch. Here BALR 12,0 specifies 0 means no branching.
L--> stands for Load
L 3,A1
Load instructuion says that load the content of the memory location(A1) into the register 3
A--> Stands for Addition
A 3,A2
Add the content of memory loction (A2) to the register 3
ST--> Stands for Store
ST 3,Result
Store the content of the register (3) to the variabke Result
Then we need to define the space for the memory variables this can done by suing DC & DS statements
DC -Define Constant
By using this we can reserve memry space for a variable as well as we can assign value to the variale
DS --> Define Storage
By using this we can only reserve space for a variable
BR 14 --> Branch 14
It halts the execution of assembler program. Its like Stoprun in cobol. |
|