written 5.7 years ago by |
Assembly Language:
An assembly language is a low level language for a computer microcontroller and other programmable device,in which each statement corresponds to a single machine code instruction.Each assembly language is specific to particular computer architecture in contrast to most high level programming languages, which is actually portable across multiple system.
An assembler create object code by translating assembling instruction mnemonics into opcodes and and by resolving symbolic names for memory location and other entities
Assembly language uses a mnemonic to represent each low level machine operation or opcode .Some opcodes need one or more operand as part of the instruction ,and most assembler can take levels and symbols as operands to represent addresses and constants instead of hard coding them into the program.
A program written in assembly language consists of a series of processor instruction and meta statements (knows variously as directives) comments and data.Assembly language instructions usually consists of an opcode mnemonics followed by a list of data arguments or parameters.These are translated by an assembler into machine language instructions that can be loaded into memory and executed .
Syntax
- Level : mnemonic operands : comments:
Example: mov destination source ; copy source to destination
The instruction tells the cpu to move or copy the source operand to the destination operand.Registers are used to store information temporarily,while the information could be
A byte of data to be processed
- An address pointing to the data to be fetched .The vast majority of 8051 register are 8 bit register
- There is only one data type 8 bits.The 8 bits registers are shown from msb07 to lsb00.
With an 8 bit data type any data larger than 8 bit must be broken into 8 bit chunks before it is processed The most widely used registers
A=Accumulator: For all arithmetic and logic instructions
- B,$R_0,R_1,R_2,R_3,R_4,R_5,R_6,R_7$
- DPTR: Data pointer and PC.
Instruction Set:
Instruction set is a collection of instructions are used in 8051 to perform specific applications Total 4 types of instruction sets are available in 8051.those are discussed in below
Types of Instruction Set:
1)Data transfer Instruction Set
2) Arithmetic Instruction Set
3) Logical Instruction Set
4) Branch Instruction Set.
1) Data transfer Instruction Set:
Is used for transfer the data from one place to another place this instruction set having one mnemonics and to operands.
In this to operands one is source operand and another is destination operand. In this Instruction Set mnemonics the is “mov”, operands are either constant data register addresses or indirect registers those examples are given below
Syntax :Mov Destination, Source
According to above syntax whatever the data in source operand that is moved into destination operand
Example: Mov a data:Move a data to accumulator
Mov addr A:Move accumulator to addreaa; Mov Rn,addr:move data in that address to internal RAM. Mov@R1,# data;move data to internal ram with address contained in Ri; Mov,Iptr#data(16 bit);Mov 16 bit data into data pointer
Above instruction are to transfer the data from source to destination and those operands are related to internal RAM sections only,Above examples and remaining examples of data transfer instruction set explanations as given below(In addressing mode examples)
AB registers are used for arithmetic instructions .They can be accessed by direct mode as special function registers. B=Address 0F0 h, A=Address 0E0 h, -use Acc for direct mode
Stack Oriented Data Transfer:-
Another form of register indirect addressing but using SP.
Examples: MOVSP,#0*40:Initialize SP
PUSH 0*55;SP$\leftarrow SP+1,M[SP]\leftarrow M[55]$i.e. $M[41]\leftarrow M[55]$
POP B;$B \leftarrow M[55]$
The stack is a section of the RAM used by the CPU to store information temporarily,this information could be data or address.
Addressing Modes
It is a way to address any operand i.e an addressing modes refers to how you are addressing a given memory location.Total 5 types of addressing modes are available in 8051.Those are given in below and each of these addressing modes provides important flexibility.
Types of addressing modes:-
There are four types of different addressing modes:-
1) Immediate addressing mode 2)Register addressing mode 3) Direct addressing mode 4)Indirect addressing mode 5)Indexed addressing mode.
Immediate addressing mode
Specify data by its value.
In this,data is specified in the instruction itself.
The value of constant can follow the opcode in program memory.