���令

���令 - Symbol MOV x,y ADD x,y SUB...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Symbol MOV x,y ADD x,y SUB x,y CMP x,y DEC x INC x NEG x LEA x,y JMP x JCXZ x LOOP x x EQU y XCHG x,y assign y � � x x, y � � � � � � � � x, y � � � � � � � � � x � � 1 x � � 1 x � � 2's complement y ¨ æ • x ‚ ı • “ * � � — MF ı x ı x Description x, y ¨ æ • “ * � SUB \* • “ * � � ‚ v … “ * � � flags � ¶ � x( destination label ) � � CX �� � � � � � � 1 � CX � � 0 � � CX � � 0¨ æ • x( destination label ) � � CX � ( � � CX) for loop� � � � � � � � � x( destination label ) � � ¨ æ •“* � � x y � �� x � � � ��� � � y � � LF EQU 0Dh¨ æ • LF � � 0Dh Signed Jumps Symbol Description JG / JNLE jump if greater than, jump if not less than or equal to JGE / JNL jump if greater than or equal to, jump if not less than or equal to JL / JNGE jump if less than, jump if not greater than or equal JLE / JNG jump if less than or equal, jump if not greater than Unsigned Signed Jumps Symbol JA / JNBE JAE / JNB JB / JNAE JBE / JNA Single­Flag Jumps Symbol JE / JZ JC JNC JO JNO JS JNS JP / JPE Description jump if equal, jump if equal to zero jump if carry jump if no carry jump if overflow jump if no overflow jump if sign negative jump if nonnegative sign jump if parity even �� Logic, Shift, and Rotate Instructions Symbol Description ZF = 1 ZF = 0 CF = 1 CF = 0 OF = 1 OF = 0 SF = 1 SF = 0 PF = 1 PF = 0 Description jump if above, jump if not below or equal jump if above or equal, jump if not below jump if below, jump if not above or equal jump if equal, jump if not above ZF = 0 and SF = OF SF = OF SF <> OF ZF = 1 or SF <> OF Condition for Jump Condition for Jump ZF = 0 and CF = 0 CF = 0 CF = 1 CF = 1 or ZF = 1 Condition for Jump JNE / JNZ jump if not equal, jump if not zero JNP / JPO jump if parity odd NOT x AND x,y OR x,y XOR x,y SHL x,y SAL x,y SHR x,y SAR x,y ROL x,y ROR x,y RCL x,y RCR x,y P.S. S x 1's complement … • 0 � � 1 1 � � 0 x y AND � ��� � � � � H 1 x y OR ��� � � � � � H 1 x y OR ��� � � � � � H 1 x � shift y bits x P 1 �� S xS S P S xS S xS S xS S xS SHL �� � � � � � � M F � � � shift y bitsS x P = ô · ª E SHR S x P = ô· ª E á O £ �© g + x x � � � � � � � @ M x * 2 S Й M F � � � CF Й M F x S lsbS x S msbS x S lsbS x S msbS register H=ô 0S H msb S bit S y x • “ * � � — M F ��� CF�� � � � � � � H 0 Й M F � � � CF P = ô · ª E y � x/2S Й M F Й M F Й M F Й M F S � � CF ˆ ¼ ô · ª � � CF ˆ ¼ ô · ª � � CFS CF ˆ ¼ ô · � � CFS CF ˆ ¼ ô · CL H = shift y bitsS x P = ô · ª E shift y bitsS x P = ô · ª E shift y bitsS x P = ô · ª E shift y bitsS x P = ô · ª E y shift S rotate S tack & procdure ins tructions Symbol PUSH x P USHF POP x PUSHF CALL RET x S x(xS S F LAGS push S s tack S S s tack S pop S S s tack S pop S S p rocedure xH S = RET Ø ½ ô · ª S Multiplication and Divis ion Ins tructions Symbol MUL x S x Ø ½ ô· ª S xؽ ô · ª S x Ø ½ ô· ª E S xؽ ô · ª E F byte S x S AL F wordS x S AX H unsigned multiplication byte S x S AL wordS x S AX s igned multiplication H Description H AX H D X S AX AX H D X H S AX SP S x bytes S p rocedure word S word S xS SP S F LAGS S popS 1S Description word ) push S s tack S SP S 1S xS s tack S IMUL x DIV x x Ł œ • “ * byte � x � AX A X • “ * � � — MF AH Ł œ • “ * AL x Ł œ • “ * word� x � DX:AX DX:AX \ * • “ * � � ‚ } … “ * � � DX Ł œ • “ ¶ AX ��� ��� � � Ł unsigned division IDIV x x Ł œ • “ * byte � x � AX A X • “ * � � — M F AH Ł œ • “ * AL x Ł œ • “ * ord� x � DX:AX DX:AX \ * • “ * � � ‚ } … ¶ “ * � � DX Ł œ • “ w AX � � � � � � � � Ł signed division �� IDIV �� � � � � � Æ £ ' T + � � Ł œ • word � � � � � IDIV �� � � � � � Æ Ł œ • byte � � � £ ' T +�� �� � � � � bits � � � � � � � � Ł � � � � bits � � � � � � � � Ł signed bit � � signed bit � � CWD CBW String operations � � � Symbol CLD STD REP MOVSB/MOVSW REPNE SCASB/SCASW REPE CMPSB/CMPSW DF � � 0 DF � � 1 CX � � 0 � � � � ��� � 1 MOVSB � MOVSW ��� � �� � � CX � Description CX � � 0 • “ * � �— M F SCASB � SCASW � �� � �� � � AL AX • “ * � �— M F � CX � � 1 CX � � 0 � � � � � ��� Ł destination arry • “ * � � — M F � � � CMPSB � CMPSW ��� � �� � � CX � � 1 String operations � string operations DF Ł œ • * 0 • “ * � � — M F � � � DI SI � DI SI œ • “ * 1 or 2 DF œ • * 1 • “ * � � — M F � � � DI SI � DI SI Ł œ • “ * or 2 1 Ł œ • “ xxSBŁ œ • “ 1Ł œ • “ xxxSWŁ œ • “ 2 x Symbol MOVSB / MOVSW STOSB / STOSW LODSB / LODSW SCASB / SCASW CMPSB / CMPSW Source DS : SI AL / AX DS : SI AL / AX DS : SI Destination ES : DI ES : DI AL / AX ES : DI ES : DI Description move one byte from source to destination move AL/AX to the destination at ES:DI move one byte from source at DS:SI into AL/AX subtracts the string byte at ES:DI from AL/AX the byte/word at DS : SI ­ the byte/word at ES:DI \*• “*�� �: Ł s ı • * � � ‡0� � ADD A,#data 00100100(B) � � � (SYMBOLIC) • “*�� • “* � � � � � ;B fi ø • “ �� � ��� �� ��@ MF �������� �� � 7 @� � H ��� �� ��� MF ��������� �� � @M F �� (ASSEMBLER) \*•“* �� • “*���� \*•“* �� • “*��� 8051/8052 fiø•“ * X8051 XASM5l fiø• � “* ���� � ��—sı � •: � (LABEL): �� �� ; � (1) � (LABEL) ������ � Æ£ ' T+��H���� � (2) �� (OP CODE): sı• “*��— M F �� (3) �� (OPERAND): \*•“*�� • “*���� � �������— 0 ­ 3 � (4)� �� � �� ��— (:) fi ø • “* � (5) � (;)� � � � �� ��— s �: TEST: ADD A R0 ; RO fi ø • “ * � A fi ø • “ * � � � � � � � — s l � � 2 � ��� : INC R1 ; Rl � � � � � � � � � — s 1 A Rl æ “* � • 8051/8052 t t (Address Mode)s \F· ª F þ ·ª F ‘ p 8051 K û· ##1 I ƒ ñ · ª (Direct Addressing) ##2 I ƒ ñ · ª (Indirect Addressing) ##3 I ƒ ñ · ª F (Register Addressing) ##4 I ƒ ñ · ª (Immediate Addressing) ##5 I ª ƒ ñ · (Indexed Addressing) ##6 I ƒ ñ · ª (Bit Addressing) ##1 I ƒ ñ · ª H šM F @›MF (RAM) IF K û ª ƒñ· (SFR)t t: MOV A,3FH ; � � 3FH æ • “ * � � A ADD A,30H ; � � 30H æ • “ * � � A ##2 I ƒ ñ · “ H �� ��� M F @›M �� ��8� (POINTER)t 8051/8052 Iƒ ñ · ª F � ß ROt Rl,SP,DPTRIƒ ñ · F K ª Iƒ ñ · ª "@" RO,R1 t 8 s\F F ·ª ‘ ·ª F p RAM t t RAM t 256 BYTE(t 00H-FFH) t: MOV RO,#70H MOV A,@R0 ; � � RAM � 70H � � � � � � �� A MOVX A,@RO ; � � RAM � 70H � � � � � � � � A SP Iƒ æ• “(S TACK POINTER)I ªF ·ƒ ñ 8 IƒªF ·ñ s \ F·ªF A•F ª þ· p : PUSH 3OH � RAM t 30H s \ F· “ *�� A•F ª þ· p t SP s F · “ *�� A•F \ ª þ· p SP=50Ht Iƒñ· ª 30 H �� K û 51H t DPTR �� K û 16 @ ª · û * �� Й M F 65536 t BYTE �� K RAMª · Iƒñ ROM t ª ·F Iƒñ �: MOV DPTR,#5678H ; æ • “ 5678H � � DPTR MOVX A,@DPTR ; � � RAM � 5678H � � � � � � � �8 ##3 I ƒ ñ •“* 8051/8052 t RAM t RO-R7 Iƒñ F ·ª Iƒñ F ·ª : MOV A,R7 ; � � � ADD A,R3 ; � � � � 8 Iƒñ Kª· A RO-R7 �K A A R7 æ • “ * � � R3 æ • “ * � � 8051/8052 (BANK)K 5ð·ªF è RO-R7 p D£ á © T : H (PSW) t RSl,RSO K5ð · ªF è t ##4 K 5ð · ª H šMF @› "# "ð» û · ªF è Ð ™MF : MOV A #30H ;8 • “ 30H 8 • “ A MOV R5 #05H ;8 • “ 05H � R5 � � � ##5 K 5ð · “ 8051/8052 » ROM (K5ðª è · )t H šMF @›M H šMF @›M p D£ © á T + * DPTR (K 5𪠷 F )t P C (K5ð · ª ) » è t At : MOV A #30H MOV DPTR #300H MOVC A,@A+DPTR ;8 • “ * � � 330H(30H+300H)8 • “ �� A ##6 K 5ð · “ ð»û· “ *��—MF�� � (RAM) K ª 5ð· *�� (SFR)ð ª » ·û *��—MF�� � � 8051/8052 t H M F�� � � � � � � � � � @ › t (SFR)t 8051/8052 8051/8052 è H M F�� � � � � � � � � � @ K5ð·ª F : SETB C ;8 • “ * C 1 SETB P1.0 ; � � l(Pl) � 0 � � 1 MOV C ACC.2 ; � � � ACC � 2� � � � � � � � Ł » ß =============================================================== 8051/8052 K 5ð · ª F 8051/8052 p t: £©TT á D H 8051/8052 t MOV P r ú · Éú ·ªE MOVZX P r ú · ª 8bit MOVSX P r ú · ª Éú· ª E XCHG P r ú · ª \E·ª E ª Й M F • É F · © T F ª E T x SP P r ú · ª s SS:[SP-2]S SP S 16bitS bit S Ð E À á ˜ ™ M þ O£ ™ M PUSH S POP S Éú · ª E Ð SS:[SP-2]P r ú · ª E PUSHA S PUSH ax,cx,dx,bx,sp,bp,si,di POPA S POP di,si,bp,sp,bx,dx,cx,ax PUSHAD S eax,ecx,edx,ebx,esp,ebp,esi,edi POPAD S edi,esi,ebp,esp,ebx,edx,ecx,eax XLAT P r ú· ª DS:[BX+AL]S [0 J • É [S • É • É • É [S [S [S +2]S +2]S +2]S +2]S +2]S AL JlJ DS ES SS FS GS J›MF w LEA P r ú · ª E LDS [S LES [S LSS [S LFS [S LGS [S P r ú · ª E ]P r ú · ª E ]P r ú · ª E ]P r ú · ª E ]P r ú · ª E • É [S MOVSBS MOVSWS MOVSD H »ô· ª DS:[SI]S ES:[DI]S CMPSBS CMPSWS CMPSD H »ô · ª DS:[SI] ES:[DI]S 1/2/4 bytesS 1/2/4 bytesS SI S DI S 1/2/4 SI S DI S 1/2/4 SI S 1/2/4 STOSBS STOSWS STOSD H » ô· ª DS:[SI]S AL/AX/EAXS SCASBS SCASWS SCASD H »ô· ª DS:[SI] AL/AX/EAXS SI S 1/2/4 LODSBS LODSWS LODSD H »ô· ª DS:[SI] AL/AX/EAX � � � ADD H » ô � �� ACD H » ô � �� • � • � “ �ł “ �ł Ðú Ðú Ðú Ðú Ðú Ðú · T T x · C · · C SI 1/2/4 INC S � � � � ��ł SUB H » ô • “ � � � ��ł S SBB � � � ��ł DEC S CMP H s S MUL S � � � ��ł »ô • “ � � � ��Æ O £ © S AL/AX/EAX � � � � � � � � ł AX/DX:AX/EDX:EAX AX/DX:AX/EDX:EAX IMUL S H» · “ * AL/AX/EAX � � � � � � � � ł — œ • IMUL H » • “ \* • “ * � � •“ *�� IMUL � � � � � � � � ł \* • “ * � � • “*�� DIV S � � � X/DX:AX/EDX:EAX ��� AX/DX:AX/EDX:EAX ¤ œ • “ * � � AL/AX/EAX¤ œ • “ AH/DX/ IDIV ¨ aú · “ * AX/DX:AX/EDX:EAX ¤ œ • “ * � � AH/DX/EDX CBW S � AL ¤ ú ú ú· CWD S � AX ¤ CWDE S CDQ S AX ¤ •“ •“ AX DX:AX “ EAX “ EDX:EAX AL/AX/EAX¤ œ • “ EAX ¤ œ · AND ¨ a ú • “ ¨ aú • “ * � � and � OR ¨ a œ • “ ¨ a œ • “ * � � or � XOR ¨ a ú • “ ¨ aú • “ * � � xor � TEST ¨ a ú · “ ¨ aú· “ * and X • “* � �— MF� NOT S ¨ aú • “ * � not � � BT ¨ a œ • “ S � n� � � �� � �P BTC ¨ a ú S n� BTR ¨ a ú S n� BTS ¨ a ú S n� • “ � �� � �P • “ � �� � �P • “ � �� � �P n n n n bit ¤ • bit ¤ bit � � bit � � bit � � bit � � C� C� � C¤ C¤ not � � � n bit bit bit 0 1 œ • “* � n œ • “* � n n��� n��� BSF ¨ a ú • “ � �� � �P • BSR ¨ a ú • “ � �� �� P œ • “ * bit n = 1 � œ • “ * bit n = 1 � CLC X rú · · STC X rú C � C � 0 1 CMC S not C � CLD X rú STD X rú CLI X rú STI X rú LAHF ���� SAHF S AH � � bit0~bit7 X œ • “ AH • D � • D � • I � • I � 0 1 0 1 � � � � bit0~bit7 NEG S S not X œ • “ * bit SHR S CL X rú • “*� � SHL S CL X rú •“*� � SAR S Xrú •“* SAL S X rú •“* CL �� CL �� bit � bit � bit � bit � bit � bit � bit � CL � CL � bit7 X CL � CL � � CL � � CX bit7 bit0 0 0 bit0 � bit7 � C� C� bit0 � C� C� C� C� œ • “ * � CL � bit0 0 bit7 � ROR S CL Xrú •“*� � ROL S CL Xrú •“*� � RCR S CL Xrú •“*� � bit7 X bit0 X œ • “ bit0 œ • “ bit7 CL œ •“*� RCL S 1E- q · ª JMP S � �� S Jxx S 1* - q • S AAA AAS � “ CL bit � C( 8 q • “ * � CL ��H �� H H AL � � H H H H H H Û Û ú Û ú Û ú · Û ú AL � � H AL � � H AL � � H AL � � H AL � � Ð Ð ™ ™ M M F F pop ip Û ú · ú · AH(E q 8 · · ª AH (E q 8 AL AL ª AL AL AL � AL AL ª ª AL DAA bit( * q • “ 8 bit ( * q • “ 8 · · DAS AAM AH(E q 8 AH (E q 8 AAD ª CALL S PÛú · E ª RET S PÛú· E RETF S P Ûú • “ *� � — INT S S IRET P Ûú· S INTO 1 -q · � � � �� � H “ *� � — “O M F � � � pop cs � pop ip MF � 1( - q · int 04h ���H œ CX � 1 LOOPS LOOPZS LOOPNZ S ( -q· ª CX>1 Z=1 Z=0 � � � � REPS REPZS REPNZ S (movs/cmps/stas/scas) CX>1 Z=1 Z=0 � � � � AL/AX � � � � H t ß • CX � 1 IN S (AL/AX)S ˜ Rï· ªE port R OUT S P tû · ªE (DX)S Ð (DX) • ªE (AL/AX) ™MF port INSBS INSWS INSD ˜ Rï · port dx � � ES:[DI] OUTSBS OUTSWS OUTSD ˜ Rï · DS:[SI] � � port dx ...
View Full Document

This note was uploaded on 11/09/2010 for the course IM 405 taught by Professor Irvine during the Spring '10 term at UNCuyo.

Ask a homework question - tutors are online