Microcontroller 8051 - assembly language ppt

40 433 0
Microcontroller 8051 - assembly language ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... MOV R4,#22h MOV R5,#0DBh ;Call the 16-bit addition routine LCALL ADD16_16 ADD16_16: ;Step 1 of the process MOV A,R7 ;Move the low-byte into the accumulator ADD A,R5 ;Add the second low-byte to the accumulator MOV R3,A ;Move the answer to the low-byte of the result ;Step 2 of the process MOV A,R6 ;Move the high-byte into the accumulator ADDC A,R4 ;Add the second high-byte to the accumulator, plus carry... unconditional jump It is a 3-byte instruction It allows a jump to any memory location from 0000 to FFFFH AJMP(absolute jump) In this 2-byte instruction, It allows a jump to any memory location within the 2k block of program memory SJMP(short jump) In this 2-byte instruction The relative address range of 00FFH is divided into forward and backward jumps, that is , within -1 28 to +127 bytes of memory... with 8051 256's 1's R6 R7 + R4 R5 R2 R3 = 65536's R1 1.Add the low bytes R7 and R5, leave the answer in R3 2.Add the high bytes R6 and R4, adding any carry from step 1, and leave the answer in R2 3.Put any carry from step 2 in the final byte, R1 Steps 1, 2, 3 MOV A,R7 ;Move the low-byte into the accumulator ADD A,R5 ;Add the second low-byte to the accumulator MOV R3,A ;Move the answer to the low-byte... for CLR: CLR A ;A=0 DEC INC byte byte ;byte=byte-1 ;byte=byte+1 INC DEC DEC R7 A 40H ; [40]=[40 ]-1 RR – RL – RRC – RLC A EXAMPLE: RR A RR: RRC: C RL: RLC: C ANL - ORL – XRL Bitwise Logical Operations: AND, OR, XOR EXAMPLE: MOVR5,#89H ANL R5,#08H CPL Example: MOV L01: CPL MOV ACALL SJMP A ;1’s complement A,#55H ;A=01010101 B A P1,A DELAY L01 Stack in the 8051 • The register used to access the stack is... the high-byte of the result ;Step 3 of the process MOV A,#00h ;By default, the highest byte will be zero ADDC A,#00h ;Add zero, plus carry from step 2 MOV MOV R1,A ;Move the answer to the highest byte of the result ;Return - answer now resides in R1, R2, and R3 RET Timer & Port Operations • Example: Write a program using Timer0 to create a 10khz square wave on P1.0 MOV TMOD,#02H ;8-bit auto-reload... Instructions Another control transfer instruction is the CALL instruction, which is used to call a subroutine • LCALL(long call) This 3-byte instruction can be used to call subroutines located anywhere within the 64K byte address space of the 8051 • ACALL (absolute call) ACALL is 2-byte instruction the target address of the subroutine must be within 2K byte range Example: Write a program to copy a block of... LCALL,LJMP Indexed Addressing Mode • This mode is widely used in accessing data elements of look-up table entries located in the program (code) space ROM at the 8051 MOVC A,@A+DPTR (A,@A+PC) A= content of address A +DPTR from ROM Note: Because the data elements are stored in the program (code ) space ROM of the 8051, it uses the instruction MOVC instead of MOV The “C” means code Some Simple Instructions... accumulator ADD A,R5 ;Add the second low-byte to the accumulator MOV R3,A ;Move the answer to the low-byte of the result MOV A,R6 ;Move the high-byte into the accumulator ADDC A,R4 ;Add the second high-byte to the accumulator, plus carry MOV R2,A ;Move the answer to the high-byte of the result MOV A,#00h ;By default, the highest byte will be zero ADDC A,#00h ;Add zero, plus carry from step 2 MOV R1,A ;Move... Stack in the 8051 • The register used to access the stack is called SP (stack pointer) register 7FH • The stack pointer in the 8051 is only 8 bits wide, which means that it can take value 00 to FFH When 8051 powered up, the SP register contains value 07 Scratch pad RAM 30H 2FH Bit-Addressable RAM 20H 1FH 18H 17H 10H 0FH 08H 07H 00H Register Bank 3 Register Bank 2 Stack) Register Bank 1) Register Bank 0... of RAM will replace in Accumulator Note 2: MOV A,R3 ≡ MOV A,3 ADD A, Source ;A=A+SOURCE ADD A,#6 ;A=A+6 ADD A,R6 ;A=A+R6 ADD A,6 ;A=A+[6] or A=A+R6 ADD A,0F3H ;A=A+[0F3H] SUBB A, Source ;A=A-SOURCE-C SUBB A,#6 ;A=A-6 SUBB A,R6 ;A=A+R6 MUL & DIV • MUL MOV MOV MUL AB ;B|A = A*B A,#25H B,#65H AB ;25H*65H=0E99 ;B=0EH, A=99H • DIV MOV MOV DIV AB ;A = A/B, B = A mod B A,#25 B,#10 AB ;A=2, B=5 SETB bit CLR . ) 16 Register s A B R0 R1 R3 R4 R2 R5 R7 R6 DPH DPL PC DPTR PC Some 8051 16-bit Register Some 8-bitt Registers of the 8051 SP Memory mapping in 8051 • ROM memory map in 8051 family 0000H 0FFFH 0000H 1FFFH 8751 AT89C51 8752 AT89C52 4k. ;A=A+6 ADD A,R6 ;A=A+R6 ADD A,6 ;A=A+[6] or A=A+R6 ADD A,0F3H ;A=A+[0F3H] SUBB A, Source ;A=A-SOURCE-C SUBB A,#6 ;A=A-6 SUBB A,R6 ;A=A+R6 MUL & DIV • MUL AB ;B|A = A*B MOV A,#25H MOV B,#65H MUL AB. • This mode is widely used in accessing data elements of look-up table entries located in the program (code) space ROM at the 8051 MOVC A,@A+DPTR (A,@A+PC) A= content of address A +DPTR from

Ngày đăng: 29/03/2014, 19:20

Từ khóa liên quan

Mục lục

  • Slide 1

  • Numerical Bases Used in Programming

  • Hexadecimal Basis

  • Decimal, Binary, BCD, & Hexadecimal Numbers

  • Slide 5

  • Memory mapping in 8051

  • Slide 7

  • Addressing Modes

  • Register Addressing Mode

  • Direct Addressing Mode

  • Register Indirect Addressing Mode

  • Immediate Addressing Mode

  • Relative, Absolute, & Long Addressing

  • Indexed Addressing Mode

  • Some Simple Instructions

  • Slide 16

  • MUL & DIV

  • Slide 18

  • Slide 19

  • Slide 20

Tài liệu cùng người dùng

Tài liệu liên quan