02.machine Structure - Machine Language - Assembly Language
02.machine Structure - Machine Language - Assembly Language
02.machine Structure - Machine Language - Assembly Language
Working register: are the memory devices that serve as “scratch pad” for the
instruction interpreter.
General register: are used by programmers as storage locations and for special
functions.
Memory address register (MAR): contains the address of the memory location
that is to read from or stored into.
Memory buffer register (MBR): contain a copy of the content of the memory
location whose address is stored in MAR. The primary interface between the
memory and the CPU is through memory buffer register.
This instruction has three parts first the opcode i.e. ADD, second is the number
of the register that contain the first operator, third is the memory location
address that contain the second operand.
Memory
The basic unit of memory in Unit of memory Bytes Length in bits
360 and 370 is a byte (eight
bits of information). It means,
Byte 1 8
each addressable position in
memory can contain a byte of
Half word 2 16
information. There are
facilities to operate on
contiguous bytes in basic Word 4 32
units. The basic units are as
follows: Double word 8 64
• Then the operand of the instruction is checked and the corresponding A smaller unit of memory of size 4 bits is called as nibble. The size of a 360
branch is taken, here ADD branch is chosen. memory is upto 224 bytes. The addressing of a 360 memory consists of three
• Then the memory location of the second operand is placed in the MAR. parts. Specifically the value of an address equals to value of the offset, plus the
• Then the content is placed in MBR. content of the base register, plus the content of the index register.
Registers In the second scheme when we use the base register then a total of
There are a total of 16 general purpose registers of 32 bits each. In addition 8+4+4+4+12(offset)=32 bits are used, saving a total of 40-32=8 bits.
there are 4 floating point register of 64 bits each. It also has a 64 bits program
status word (PSW) that contains the value of the location counter, protection The only disadvantage with this method is that the offset can take value from 0
information and interrupt status. to 4,095 locations away from the core location to which the base register is
pointing.
The general purpose registers are basically used in arithmetic and logical
operations as base registers and helps in address formation. The general Data
purpose registers also used as scratch pads for the programmers. Let us take an The 360 may store several different types of data as is depicted in the figure.
instruction A 1,901(2,15).
This is how the memory locations are addressed in case of 360 and 370. The use
of base registers in addressing is twofold.
First it helps the loader in the process of relocation (changing the content of
base register causes the code to be relocated to the specified location).
Secondly it decreases the size of instruction as follows: since the memory of 360
is of 224 hence a total of 24 bits are required to specify a particular location of
memory. This increases the size of instruction as opcode takes 8 bits and the
registers require 4 bits each and the address requires a 24 bits hence the size of
the instruction is 8+4+4+24=40 bits (without base register)
The groups of bits stored in memory are interpreted by 360 processor in Instruction
several ways. The list of different interpretation are shown in the figure are as
follow.
E.g. +541 is represented as 0000 0010 0001 1101, the first bit represents the
sign i.e. + and the rest 15 bits represents the integer 15. Where are -021 can be
represented as 0000 0010 0001 1101 i.e. 0 2 1 and -, in decimal packed form
representation. Where are + 300 is represented as 0000 0001 0010 1100.
It is more convenient to represent the numbers in hexadecimal as every
hexadecimal digit represents four binary digits and vice versa. Thus +300
which is B’0000 0001 0010 1100’ in binary can be written as X’012C’ in
hexadecimal. The prefix B and X represents binary and hexadecimal
respectively.
The instructions in 360 can be arithmetic, logical, control or transfer and special
interrupt instructions. The format of 360 instructions is as in figure above.
There are five types of instructions that differ in the type of operands they use.
1. Register operand refers to the data stored in the 16 general purpose
registers (32 bits each). Registers being high-speed circuits provide faster
access to data than the data in the core. E.g. Add register 3, 4 causes the
contents of the contents of the register 4 to be added to that of register 3 Address = c(B2) + c(X2) + D2
and stored back in the register = c(5) + c(0) + 16
3. The instruction is = 1000 + 0 +16
represented as given in the = 1016
diagram. The is called as RR
format. A total of two bytes are Hence the instruction cause the content of the word (32 bits) located at address
required to represent the RR 1016 to be added to the contents of general purpose register 3 (32 bits), with
instruction 8 bits for opcode the resulting sum left in general register 3.
and 4 bits each of register(8+4+4=16 bits =2 bytes).
2. Stored Operand refers to the data stored in the core memory. The length of
the operand depends on the specific data types. For operand of length more
that one byte the address is specified by the lowest address byte (leftmost).
E.g. 32 bits binary fixed point fullword with value +237(X’00 00 01 0B’ in
hexadecimal), stored in location 1016, 1017, 1018 and 1019 as depicted
below is said to be located at 1016.
A list of 360 op code with the instruction format and their hexadecimal code are
listed in the table below:
MACHINE LANGUAGE
In this section we will dealing with the machine language of 360 machine. We
will not be using 0’s and 1’s or hexadecimal, rather we will be using mnemonics
for writing machine level programs.
The figure shows a load instruction as a series of 0’s and 1’s that can be easily
represented in the mnemonic code as L 2, 924(0,1). The program that would be
used over here adds the number 49 to the contents of 10 adjacent fullwords in
memory, under the following assumptions
Each instruction over here is a fullword (4 bytes) stating from relative address 0
and absolute address 48. The program does the following.
So whenever Nancy refused they replace Nancy with May in step 4 and repeated
the process from the start. This process has two programming techniques. First
was the instruction step 3 can be treated as data and can be changed. Secondly Address modification of the instruction occurs as shown in the figure above.
BY- KISHORE KUMAR SAHU (SR. LECTURER), DEPT. OF INFORMATION TECHNOLOGY.
13Page
LECTURE NOTES ON SYSTEM PROGRAMMING
First process is similar to that of the process discussed in last technique. Rest of
the steps in this process are as follows:
The instruction can be explained as below: 7. Load the content of 892+48=940 i.e. 10(initially) to R3.
8. Subtract the content of 888+48=936 i.e. 1 from the content of R3 and store
1. Clear the content of R4 by subtracting R4 by itself i.e. R4. the result in R3.
2. Load the content of 904+c(4)+c(1)=904+0+48=952 to R2. 9. Store the content of R3 back to 940.
3. Add contents of 948 to R2 and store it in R2. 10. Check if the content of 940 is positive.
4. Store the content of R2 back to 952. a. If positive then send the control back to instruction stored are
5. Add content of 896+48=944 i.e. 4 to the content of R4. relative address 2.
6. Branch back to relative location 2, nine times. b. Else terminate.
Here BC is a conditional opcode is used, that check for a condition (here the
In this process R4 is cleared first and used in the address calculation process. condition is that location 940 is positive) and act accordingly depending on the
Subsequently R4 is incremented each time by 4 for each iteration. result of the condition.
Looping The second process used in looping makes use of a conditional opcode BCT, that
With the use of index register, we have understood the concept of looping. We works in a manner similar to that of BC opcode and in addition to that is
will be applying looping in two ways, but for this to happen we need to decrements the looping factor by one each time it gets executed. Hence the use
assumptions to be made, that are as follows: of BCT opcode in the programming cut short our program by three bytes. Since
1. Relative location 892 contains a 10. the process is iterative one so the 3*10 bytes of executable code are reduce by
2. Relative location 888 contains a 1 ( for first method only). the use of BCT opcode. The code of this process is as in the figure.
ASSEMBLY LANGUAGE
The era of programming languages starts with machine language and end in
English language, thereby making a move from the language that are best for
machine to that are best for programmers.
So far we have machine language and mnemonic machine language. Now we
will be using assembly language for the follows reasons (advantages).
1. It is mnemonics, e.g. we use ST instead of the bit stream 0101000 for the
store instruction.
2. Addresses are symbolic, not absolute.
3. Reading is easier.
4. Introduction of data to program is easier.
It is very difficult to know for any programmer or machine to know the address =F'10', =F'49', =F'4' are the literal which would be result in the creation of a
in the core where the loader will load the program. It is only at the time of data area containing 10, 49 and 4 and replacement of the literal operand with
execution the stating address of the program is known. Assembly language has a the address of the data it describes.
machine code named BALR that sets the address of base register to the next
L 3, =F'10' is translated by the assembler to point to a full word that contains a
instruction to be executed.
10. Generally the assembler keep track of the literal with the help of a literal
Assembly program has two type of opcode, they are machine and pseudo table. This table will contain all the constants that have been requested through
opcode. The machine opcodes are translated to machine code, while the pseudo the use of literal. A pseudo opcode LTORG place the literal at an earlier location.
opcodes are not. The pseudo instruction only give information to the assembler. This is required because, the program may be using 10000 data and it become
The list of opcodes used in the program are as follows: difficult for the offset of the load instruction to reach the literal at the end of the
program.
1. USING is a pseudo code the indicates to the assembler which general
purpose register to use as a base and what its contents will be. As we do not
The program by the use of literal looks as follows:
have any specific general register acting as the base register, so it becomes
necessary to inform indicate a base register for the program. Because the
address are relative so by the knowledge of base and offset the program can
be easily be located and executed.
2. BALR is machine opcode that load a register with the next address and
branch to the address in the second field. Since second operand is 0 so the
control will go to the next instruction.
3. START is a pseudo opcode that tell the assembler where the beginning of
the program is and allows the user to give a name to the program. In this
case the name is TEST.
4. END is a pseudo code that tells the assembler that the last card of the
program has been reached.
5. Symbolic names like TEN, DATA(4), FORTY9 etc, are use in assembly In the program we make use of '*-16' with the BCT opcode. Star in a mnemonic
language to reduce the burden of calculating the address of these data means here. The expression *-16 refers to the address of the present instruction
fields. DC are pseudo opcode used to specify the symbolic names to the minus 16 locations, which is a simple loop. This type of programming is not a
constants. good practice.
6. BR 14, the last machine opcode is used to branch to the location whose The EQU pseudo code is used to assign values to the symbols. Here BASE is
address is in general purpose register 14. By convention, calling programs assigned 15. EQU can also take arithmetic expression as its operand.
leave their return address in register 14. The program on being translated to machine code do not generate any code for
Literals the pseudo code START and USING.
The same program is repeated by using literals, that are mechanisms where by
the assembler creates data areas for the programmer, containing constants he
requests.