Vous êtes sur la page 1sur 5

"The Assembly Language Programming Process"

A generic computer includes hardware concepts and software concepts. The hardware concepts include the CPU and memory. The software concepts include the code and data memory. Computer Languages: The computer languages are the sources for interaction between the user and the computer. The languages can be two types high level languages and assembly languages. Assembly languages: Assembly language uses the mnemonics for writing the program. The assembly programs use the internal registers as the part of the assembly language code. The assembly languages are used with 8051, 8086, 6502, 68000 and Z80 CPUs. Reasons for using Assembly language: To speed up the operation of the computer Assembly language will reduce the size of the program compared to machine language program. Assembly language programs are used to write programs for special situations like machine control and robot arm movement. Assembly language program will save the money. To better understanding how the CPU operate. The programs essential for writing assembly language programs:

Program Operating system program Word processing Text editor

Description DOS or Windows operating systems are used for the programming process. Assembly program mnemonics are written in the text editor. This is stored on the disk in the format of file with extension .asm. The assembler will take the .asm file from the disk and convert that into Assembler machine code. The machine code is stored in the file with extension program .obj. This program allows the user to test his program under controlled Testing program conditions. These testing programs can also called as debuggers or simulators.

"Programming Tools and Techniques"

Programming Tools and Techniques: The computer is the sequential circuit that fetches the instruction from the code memory and then decodes it. The decoded program will be executed

for giving the result to the user. The challenges faced by the beginning programmer are unfamiliarity with the tools and running of the program. A sequence of steps required for learning process for assembly language is given below.

Learning process for assembly language: Learn about the architecture of the CPU. Need to learn o the set of assembly language instructions used in the CPU. o how to use the personal computer o about the operating system o about the text editor o how to use the assembler program. o to debug the program o how to write the program in assembly language.

Continue to write the large programs.

Steps for writing the Assembly program: Write the program using the mnemonics by using the text editor. Store the edited assembly program on the disk Call the assembler for converting the assembly language program into the computer understandable language. Load the assembled machine language program form the disk into the RAM for testing purpose. Identify the errors, reedit the program, reassemble the program and again test until get the result. Flow charts: Flow charts are used for visualizing the programs. Flow chart uses five elements, they are

Symbol Purpose Action The action box is used to represent the data moves, math operations or any box other instructions used to denote the program action. Bubble This is used to represent the beginning and end of the programs. the decision symbol used for condition checking the condition outputs either Decision yes or no. The decision is represented by using diamond symbol. Line The line is used for showing the program flow. The line is used for showing the program flow. The arrow will show in what Arrow direction the information is passing. "Programming the 8051"

Assembly language programs are written as the sequence of text lines. Each line of the text is nothing but the instruction to the CPU. The syntax of the instruction of the text line is shown below.

LABEL: ........ INSTRUCTION ........ ; COMMENT(S) Labels are used to assign some name to a location in the program. The Label allowable label needs to have up to 8 characters. The instruction is any one of the coded set that have been defined by the manufacturer of the 8051. Every instruction can be converted into a unique Instruction machine language binary code that can be acted on by internal circuit of 8051. The syntax of the instruction is shown below. Mnemonic ........ operands Comments Comments are used for understanding the program in easy manner. The comments are begin with;.(semicolon)

8051 Addressing modes The way of specifying the address of the operand is called as addressing mode. The 8051 microcontroller is having four addressing modes for accessing data. Immediate Addressing mode Register Addressing mode Direct Addressing mode Indirect Addressing mode

"Data Transfer Instructions"

Moving data: The data stored at the source address are moved onto the destination address. The 8051 is using six types of op-codes for moving data. They are

Description moves the data from internal RAM source address to internal RAM destination MOV address. moves a byte data from external RAM source address to register A and vice MOVX versa. MOVC moves data from external or internal RAM source address to register A PUSH copy a byte to internal stack from internal RAM source. POP copy a byte from internal stack to internal RAM destination. XCH used to exchange data between register and internal RAM.

Op-Code

"Logical Instructions"

Logical Operations: The logical instructions in 8051 are divided into two types.

The byte level logical operations use all four addressing modes for the source of a data type. Logical operations at the BYTE level The destination address of the operartion can be the accumulator (register A), a general register, or a direct address. Status flags are not affected by these logical operations (unless PSW is directly manipulated). Example instructions are: Byte level logical operations

ANL A, #55h ; AND each bit in A with corresponding bit in number 55h, leaving the result in A. ANL 42h, R4 ; AND each bit in RAM location 42h with corresponding bit in R4, leaving the result in RAM location 42h. ORL A,@R1 ; OR each bit in A with corresponding bit in the number whose address is contained in R1 leaving the result in A. XRL R4, 80h ; XOR each bit in R4 with corresponding bit in RAM location 80h (port 0), leaving result in A.

Bit level logical operations

CPL R0 ; Complement each bit in R0 The C (carry) flag is the destination of most bit level logical operations. The carry flag can easily be tested using a branch (jump) instruction to quickly establish program flow control decisions following a bit level logical operation. The following SFR registers only are addressable in bit level operations: PSW IE IP TCON SCON Examples of bit level logical operations are as follows:

SETB 2Fh ; Bit 7 of Internal RAM location 25h is set CLR C ; Clear the carry flag (flag =0) CPL 20h ; Complement bit 0 of Internal RAM location 24h MOV C, 87h ; Move to carry flag the bit 7of Port 0 (SFR at 80h) ANL C,90h ; AND C with the bit 0 of Port 1 (SFR at 90) ORL C, 91h ; OR C with the bit 1 of Port 1 (SFR at 90)

Other Instructions

Rotate Instructions

The ability to rotate the A register (accumulator) data is useful to allow examination of individual bits. The options for such rotation are as follows:

RL A ; Rotate A one bit to the left. Bit 7 rotates to the bit 0 position RLC A ; The Carry flag is used as a ninth bit in the rotation loop RR A ; Rotates A to the right (clockwise)

Swap Instructions

RRC A ; Rotates to the right and includes the carry bit as the 9th bit. The Swap instruction swaps the accumulators high order nibble with the low-order nibble using the instruction:

Vous aimerez peut-être aussi