صفحه 1:
ان ی “4 ‎١‏ ‏0 ۳ ی ب ‎“Assembly Languag&®‏

صفحه 2:
Numerical Bases Used in Programming * Wexnderiod ۰ Ory ٠١ 600

صفحه 3:
Hexadecimal Basis ۰ Wexadevivd Digits: 4 © © © ‏و‎ 9 9 000 6 620 @=ad 29 0-9 2۴ ۳-29

صفحه 4:
Decimal, Binary, BCD, & Hexadecimal Numbers حم( © 6) كووو(09000 0400) )۱0099 5008 (, = م( © © )

صفحه 5:
Registe DPL PC rs DPTR DPH Pc Some 8051 16-bit Register OF 8 RO Ri 7 3 Ra RS RO 17 Some 8-bitt Registers of the 8051

صفحه 6:
Memory mapping in 8051 * ROO wewory wap it COG Party 0 © 000011 000011 oFFFH 57 1FFFH 09051 nied AT89C52

صفحه 7:
40 ما و مشاه موه روم ۵0 ۰ 7۳ Scratch pad RAM ۱ 30H 27 Bit Addressable RAM 20H 1FH Register Bank 3 18H 17 ae Register Bank 2 oFH Register Bank 1 (Stack) one ‏نشب‎ Register Bank 0 i egister Ban

صفحه 8:
Addressing Modes * Register * Direct _ * Register Indirect ¢ Immediate * Relative ¢ Absolute ۰ * Indexed

صفحه 9:
Register Addressing Mode MOV Rn,A jyn=0,..,7 ADD A, Rn MOV DPL, R6

صفحه 10:
Direct Addressing Mode Although the entire of 128 bytes of RAM can be accessed using direct addressing ae it is most often used to access M loc. 30 - 7FH. MOV RO, 40H MOV 56H,A MOV A, 4 ; = MOVA, R4 MOV 6, 2 ; copy R2 to R6 ; MOV RG,R2 is invalid !

صفحه 11:
Register Indirect Addressing Mode * In this mode, register is used as a pointer to the data. MOV A,@Ri __ ; move content of RAM loc. eae address is held by Ri into A (i=0 or MOV @R1,B In other word, the content of register RO or R1 is sources or target in MOV, ADD and SUBB insructions.

صفحه 12:
Immediate Addressing Mode MOV A,#65H MOV 1 MOV DPTR,#2343H MOV P1,#65H

صفحه 13:
NELALIVE, ADSOLULE, & LONG Addressing Osed vu wit juspp aed coll tostrucioes: GIOP ®COLL,OLOP LO®LL, LIOP

صفحه 14:
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 MOVCA,@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.

صفحه 15:
Some Simple Instructions MOV dest,source _; dest = source MOV A,#72H ;A=72H MOV R4,#62H ;R4=62H MOV B,OF9H ;B=the content of F9’th byte of RAM MOV 11 1۲0۷ DPL,#34H 1108 MOV P1,A ;movAto port 1 Note 1: MOV A,#72H # MOVA,72H After instruction “MOV A,72H ” the content of 72’th byte of RAM will replace in Accumulator. Note 2: MOV A,R3 = MOV A,3

صفحه 16:
ADD A, Source jA=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 j;A=A+[0F3H] SUBBA, Source j;A=A-SOURCE-C SUBB A,#6 ;A=A-6 SUBB A,R6 ;A=A+R6

صفحه 17:
MUL & DIV * MULAB _ ;B/A = A*B MOV A,#25H MOV B,#65H MUL AB 325H*65H=0E99 ;B=0EH, A=99H DIV AB ;A=A/B,B=AmodB MOV A,#25 MOV B,#10 DIV AB j;A=2, B=5

صفحه 18:
SETB bit ; bit=1 CL bit ; bit=0 SETB Cc ; CY=1 SETB 20.0 ;bit 0 from port 0 =1 SETB P3.7 ;bit 7 from port 3 =1 SETB 2 ;bit 2 from ACCUMULATOR =1 SETB 05 ;set high D5 of RAM loc. 20h Note: CLR instruction is as same as SETB ie.: CLR Cc ;CY=0 But following instruction is only for CLR: CLR A j;A=0

صفحه 19:
DEC byte sbyte=byte-1 INC byte sbyte=byte+1 INC R7 DEC A DEC 40H ; [40]=[40]-1

صفحه 20:
RR-RL-RRC-RLC A EXAMPLE: RR A RR: c > RRC: ‏ام ی‎ > RL: S => RLC: ‏مالم بج‎ >

صفحه 21:
ANL - ORL - XRL Bitwise Logical Operations: AND, OR, XOR EXAMPLE: MOV R5,#89H ANL R5,#08H CPL ۸ ;1’s complement Example: MOV A,#55H ۰ ;A=01010101 B 101: CPL A MOV P1,A ACALL DELAY 51215 1

صفحه 22:
Stack in the 8051 ¢ The register used to access the stack is called SP (stack pointer) register. ۳ Scratch pad RAM ¢ The stack pointer in the 8051 is only *“ 8 bits wide, which = 7" 1 Bit-Addressable RAM means that it can take value 00 to ae FFH. When 8051 18H ‏سب‎ 1 powered up, the ee Register Bank 2 SP register or wee contains value 07. 7 Bank 1 078 ne Register Bank 0

صفحه 23:
MOV R6,#25H 0۷ R1,#12H MOV R4,#0F3H | PUSH 6 PUSH 1 PUSH 4 OBH oBH OBH ‏اس‎ OAH OAH OAH OAH 09H 09H 09H ‏وه‎ 08H 08H 08H 08H Start 85-0811 ‏1و0 دمو‎ SP=08H SP=07H.

صفحه 24:
LOOP and JUMP Instructions Conditional Jumps : 17 Jump if A=0 JNZ Jump if A/=0 DJNZ Decrement and jump if A/=0 CJNE A,byte __| Jump if A/=byte CJNE Jump if byte/=#data reg,#data 10 Jump if CY=1 JNC Jump if CY=0 JB Jump if bit=1 JNB Jump if bit=0 JBC Jump if bit=1 and clear bit

صفحه 25:
DINZ: Write a program to clear ACC, then add 3 to the accumulator ten time A,#0 R2,#10 R2,AGAIN ;repeat until R5,A Solution: MOV MOV AGAIN: ADD A,#03 DJNZ R2=0 (10 times) MOV

صفحه 26:
LJMP(ong jum: LJMP is an 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 00-FFH is divided into forward and. backward jumps, that is , within -128 to +127 bytes of memory relative to the address of the current PC.

صفحه 27:
CALL 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 - Addresmspakeofdine 8051. ACALL is 2-byte instruction. the target address of the subroutine must be within 2K byte range.

صفحه 28:
Example: Write a program to copy a block of 10 bytes from RAM location starting at 37h to RAM location starting at 59h. Solution: MOV RO,#37h } source pointer MOV R1,#59h ; dest pointer MOV R2,#10 ; counter L1: MOV A,@RO MOV @R1,A INC RO INC R1 DJNZ R2,L1

صفحه 29:
Decimal Addition 499 + 0 0005 (0's 16 Bit Addition (OPH + COOG= 5000

صفحه 30:
Performing the Addition with 8051 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.

صفحه 31:
Steps 1, 2, 3 00 6۶ ‏موه(‎ te bu-bye too he wound OOO @,RS jOdd te peor bu-bye te ‏لص چیه و‎ 000 69,6 ‏مو(:‎ te newer t te bw-bye oP te rer DOO ®,RO jOove te kite bye tie he ‏«صاد یمیت‎ 6000 6,6۶ :10 | vero higk-bye to the wrcukior, py ary. MOO RO,® jOove te newer ty he hihebye oP the result 000 ۵,۶۵۵ {Gp dePad, te highest byte wil be zevv. 6000 ©,#OOk {Odd zerv, phe vary Prow step ۰ 000:0,0 jOove te newer ty he highest byte oP te revul

صفحه 32:
The Whole Program ‎RP‏ ليه © حم سلس ‎Perot‏ سا لسساز 60 000 ‎00 6 ‎oad te ‏سس اس‎ ir RP cod RO ‎000 66,۵6 ‎000 ۵ ‏0009-09 انا 0نا سف مسطلی م09 0 ‎ ‎۵009 ‏از‎ ) be provere ‎DOO ©,R? ;Oove be burbye ny te ‏چیه‎ ‎600 6,66 ‏موه با (۵4ز‎ burbye ty te wwoetor 600 66,۵ ‏ما جو6:‎ newer © te bu-byte oP ke rend ‎{Oey © oP te provese DOO ©,RO {Dove te hike bye kar be center ‎BODO ORE {Ode te ‏,بویت عا نا سره لمیر‎ phe ary. 000 RO, ;Dove be caver to ber hack bye oP he rem ‎{Oey O oP te ‏مدب‎ ‎DOO ©,#OOk Oy cea, te behest bye ull be aero. ‎6000 ©,40Ok {Od aor, phe vary Prow vey O. ‏فصب سحاد عابط مله صا حا ‎DOO 4,0 {ore te ower‏ 000 ‎ ‎canwer ww reetbe 19 RI, RO, aad RO. ROT‏ - موز ‎

صفحه 33:
Timer & Port Operations 0 Onte 9 prograv ustay Tier ty crede ‏و‎ (Ok square wwe vo ۳. 000: ۹00/۳94 j}O-bt ‏طحب لمصاصحصي‎ MOO TLO,F-GO ;-GO reba uche 5 “110 GETS TRO ‏از‎ LOOP: JOG TPO, LOOP jwat Por werPow CLR TPO wear tkoerO vverPlow Pray ‏رن‎ 01. ose port bit GIOP LOOP ‏اه‎ ‎GOO

صفحه 34:
Interrupts . Enabling and Disabling Interrupts . Interrupt Priority . Writing the ISR (Interrupt Service Routine)

صفحه 35:
Interrupt Enable (IE) Register : EA: Global enable/disable. - : Undefined. ET2 :Enable Timer 2 interrupt. nable Serial port interrupt. nable Timer 1 interrupt. nable External 1 interrupt. nable Timer 0 interrupt. EXO : Enable External 0 interrupt.

صفحه 36:
Interrupt Vectors Vector Address 0000H 0003H 000BH 0013H 001BH 0023H 002BH Interrupt System Reset External 0 Timer 0 External 1 Timer 1 Serial Port Timer 2

صفحه 37:
Writing the ISR Example: Writing the ISR for Timer0 interrupt ORG 0000H jreset LJMP MAIN ORG 1 ;Timer0 entry point TOISR: . ;Timer0 ISR begins RETI ;return to main program MAIN: . ;main program END

صفحه 38:
Structure of Assembly language and Running an 8051 program EDITOR PROGRAM Myfile.asm ASSEMBLER PROGRAM Myfile.Ist va Other obj file Myfile.obj LINKER PROGRAM OH PROGRAM مود آ

صفحه 39:
۲0۲۱۱۳3۱ ۶< ۷۵ ۱ Instructions ۰ 000 0,04. JC LIODEd * GETS 20.0 CLR C4.8

صفحه 40:
Set POOL: Prk Och Ove Grok ROT: Canes Pro ‏سحلت‎ ROM: Benas Prone ert RL: one Brennen bof لصوت محمد حابرا .صا سجر ‎LO:‏ ‎Baht‏ مه سس هو RO: Renee Dev. Pats Morne Cory OTS: Ga Ot OUD: Short hare 000: Gb. Crow Dov. Ob Bory COE: Gury Boormrker ‏سافان‎ ‏تست ناور‎ XOUO: Crchennye Ont ‎Bicker OR‏ عبط نرق ‎Derk Pra: Denke ete ‎8051 Instruction ‎Got‏ بسن ۶ بسن :ول هه ‎IOP: he te‏ ‎MOD: ony B Or Dot One ‎400: hey # Ose Dot Ont MOE: hey B Wow. Da bere AE: hey B reneentr ere ‏فج نا تل هيا‎ ‏مسا :ما ‏ره سم :00۵ ‎000: Deve Ornte Dre OOK: Dene Cxtraked Dercemy DOL: ‏رجا سعط جسم بیش‎ © OP: We Operon ‎OBL: Base OR ‎POP: ‏سفن بط‎ Proce Grek ‎COBW: Wiehe Od ©00, 8000: Oi bev. (D4 Oxy) NDE: Clore dry ‎COL: Orser HOO ‎ONDE: Oreprrr & share P Oe Copel ‏میس سا هه‎ ‎Rene‏ مان ره ‏سوه سم هو ‏موس سس :و0۵ هرفس ‎WO: rab‏ ‎ONO: De. ey. & hry FD Ler ٩00: ‏و مس‎ ‎AD: roy Fe Get ‎a Get ad Oke Oe‏ ل مومعل :00ل ‎

جهت مطالعه ادامه متن، فایل را دریافت نمایید.
29,000 تومان