set de instrucciones hc08

Upload: cristian

Post on 09-Jan-2016

359 views

Category:

Documents


13 download

DESCRIPTION

Describe el funcionamiento del Microcontrolador de Freescale motorola familia 08

TRANSCRIPT

  • Modos de Direccionamiento y Set de instruccionesMicrocontroladores Freescale Familia HC(S)08

  • 0. Modos de direccionamiento

  • Direccionamiento Extendido (EXT)Se especifican 16 bits con la direccccin del operando. Usado para acceder a posiciones de memoria mayores a 00FFH.Ejemplo: LDA 1210HDireccionamiento Indexado sin Offset (IX)Se especifica el contenido del Registro Indice H:X como direccin del operandoEjemplo: CLR ,XDireccionamiento Indexado con Offset de 8 bits (IX1)Offset de 8 bits sin signo + registro H:X sin signo = posicin de memoriaRegistro H:X no es modificadoEjemplo: CLR 43H,XDireccionamiento Indexado con Offset de 16 bits (IX16)Offset de 16 bits sin signo + Registro H:X sin signo = posicin de memoriaRegistro H:X no es modificadoEjemplo: CLR 0230H,XDireccionamiento Indexado con el SP y Offset de 8 bits (SP1)Offset de 8 bits sin signo + Registro SP sin signo = posicin memoria Registro SP no es modificado Ejemplo: LDA 5,SP

  • Direccionamiento Indexado con el SP y Offset de 16 bits (SP2)Offset de 16 bits sin signo + Registro SP sin signo = posicin memoria Registro SP no es modificado Ejemplo: LDA 0500H,SPDireccionamiento Relativo (REL)Usado en todas las instrucciones de bifurcacin condicionales Si la condicin es:VERDADERA PC = PC + offset de 8 bits con signoSINO PC no es afectadoEjemplo: BEQ 1355HDireccionamiento Indexado sin Offset y PostIncremento (IX+)El Registro indice H:X contiene la direccin del operando.Despues que la direccin del operando es hallada, H:X es incrementado en 1Ejemplo: CBEQ X+,2480HDireccionamiento Indexado con Offset de 16 bits y PostIncremento (IX1+)Igual al direccionamiento indexado con offset de 8 bits , pero despus que la direccin del operando es calculada, H:X es incrementado en 1Ejemplo: CBEQ 50H,X+,2480H

  • Direccionamiento Memoria a memoriaUsado para mover informacin desde una posicin de memoria a otraNo usa ni afecta registros de la CPU (excepto cuando se usa direccionamiento indexado con post incremento)Cuatro variantes: Inmediato a Directo Directo a Directo Indexado a Directo con Post Incremento Directo a Indexado con Post IncrementoDireccionamiento Memoria a memoriaInmediato a Directo (IMD)La Fuente es un byte valor inmediatoEl Destino debe estar en las primeras 256 posiciones del mapa de memoriaEjemplo: MOV #45H,67HDireccionamiento Memoria a memoriaDirecto a Directo (DD)La Fuente debe estar en las primeras 256 posiciones del mapa de memoriaEl Destino debe estar en las primeras 256 posiciones del mapa de memoriaEjemplo: MOV 60H,80H

  • Direccionamiento Memoria a memoriaIndexado con PostIncremento a Directo (IX+D)La Fuente puede ser cualquier lugar en el mapa de memoriaEl Destino debe estar en las primeras 256 posiciones del mapa de memoriaDespues que la direccin del operando es hallada, H:X es incrementado en 1Ejemplo: MOV X+,25HDireccionamiento Memoria a memoriaDirecto a Indexado con PostIncremento (DIX+)La Fuente debe estar en las primeras 256 posiciones del mapa de memoriaEl Destino puede ser cualquier lugar en el mapa de memoriaDespues que la direccin del operando es hallada, H:X es incrementado en 1Ejemplo: MOV 75H,X+

  • 1. Instrucciones Aritmticas

  • ASL opr8ASL ,XASL opr8,X ASL opr8,SPCorrimiento Aritmtico a la izquierdaC (opr8) 0C (HX) 0C (opr8 + HX) 0C (opr8 + SP) 0(DIR) 8 bit direct(IX) indexed no offset(IX1) indexed, 8 bit offset(SP1) SP with 8 bit offset ASLA Corrimiento Aritmtico a la izquierda de AC A 0 (INH) inherent mode ASLXCorrimiento Aritmtico a la izquierda de XC X 0 (INH) inherent mode ASR opr8ASR ,XASR opr8,X ASR opr8,SP Corrimiento Aritmtico a la derechaM7 (opr8) CM7 (HX) CM7 (opr8 + HX) CM7 (opr8 + SP) C (DIR) 8 bit direct(IX) indexed, no offset(IX1) indexed, 8 bit offset(SP1) SP with 8 bit offset ASRA Corrimiento Aritmtico a la derecha de A A7 A C (INH) inherent mode ASRXCorrimiento Aritmtico a la derecha de XX7 X C (INH) inherent mode CMP #opr8CMP opr8CMP opr16CMP ,XCMP opr8,XCMP opr16,XCMP opr8,SPCMP opr16,SP Comparar el Acumulador con MemoriaA - opr8A - (opr8)A - (opr16)A - (HX)A - (opr8 + HX)A - (opr16 + HX)A - (opr8 + SP)A - (opr16 + SP) (IMM) 8 bit immediate(DIR) 8 bit direct(EXT) 16 bit extended(IX) indexed no offset(IX1) indexed, 8 bit offset(IX2) indexed, 16 bit offset(SP1) SP, 8 bit offset(SP2) SP, 16 bit offset

  • CPHX #opr16CPHX opr16 Comparar H:X con MemoriaHX - opr16HX - (opr16) (IMM) 16 bit immediate(DIR) direct, 16 bit data CPX #opr8CPX opr8CPX opr16CPX ,XCPX opr8,XCPX opr16,XCPX opr8,SPCPX opr16,SP Comparar Registro X con MemoriaX - opr8X - (opr8)X - (opr16)X - (HX)X - (opr8+HX)X - (opr16+HX)X - (opr8+SP)X - (opr16+SP) (IMM) 8 bit immediate(DIR) 8 bit direct(EXT) 16 bit extended(IX) indexed no offset(IX1) indexed, 8 bit offset(IX2) indexed, 16 bit offset(SP1) SP, 8 bit offset(SP2) SP, 16 bit offset DAA Ajuste Decimal de Acumulador A10 (INH) inherent addressing DEC opr8DEC ,XDEC opr8,XDEC opr8,SP Decrementar(opr8) = (opr8) 1(HX) = (HX) 1(opr8+HX)=(opr8+HX)1(opr8+SP)=(opr8+SP) 1 (DIR) 8 bit direct(IX) indexed,no offset(IX1) indexed,8 bit offset(SP1) SP with 8 bit offset DECA Decrementar A A = A - 1 (INH) inherent mode DECXDecrementar XX = X - 1 (INH) inherent mode DIVDivisinA = H:A H = Residuo X(INH) inherent addressing INC opr8INC ,XINC opr8,XINC opr8,SP Incrementar(opr8) = (opr8)+ 1(HX) = (HX) + 1(opr8+HX)=(opr8+HX)+1(opr8+SP) = (opr8+SP)+ 1 (DIR) 8 bit direct(IX) indexed no offset(IX1) indexed,8 bit offset(SP1) SP with 8 bit offset

  • INCA Incrementar AA = A + 1 (INH) inherent mode INCXIncrementar XX = X + 1 (INH) inherent mode MUL Multiplicacin X:A = A * X (INH) inherent addressing NSA Nibble Swap Accumulator A = A[3:0]:A[7:4] (INH) inherent addressingSBC #opr8SBC opr8SBC opr16SBC ,XSBC opr8,XSBC opr16,XSBC opr8,SPSBC opr16,SP Resta con Prstamo A = A - C - opr8A = A - C - (opr8)A = A - C - (opr16)A = A - C - (HX)A = A - C - (opr8+HX)A = A - C - (opr16+HX)A = A - C - (opr8+SP)A = A - C - (opr16+SP) (IMM) 8 bit immediate(DIR) 8 bit direct(EXT) 16 bit extended(IX) indexed no offset(IX1) indexed 8 bit offset(IX2) indexed 16 bit offset(SP1) SP with 8 bit offset(SP2) SP with 16 bit offset SUB #opr8SUB opr8 SUB opr16 SUB ,XSUB opr8,X SUB opr16,X SUB opr8,SP SUB opr16,SP RestaA = A - opr8A = A - (opr8)A = A - (opr16)A = A - (HX)A = A - (opr8+ HX)A = A - (opr16+ HX)A = A - (opr8+ SP)A = A - (opr16+ SP) (IMM) 8 bit immediate(DIR) 8 bit direct(EXT) 16 bit extended(IX) indexed no offset(IX1) indexed, 8 bit offset(IX2) indexed, 16 bit offset(SP1) SP with 8 bit offset (SP2) SP with 16 bit offset TST opr8 TST ,XTST opr8,X TST opr8,SP Test for Negative or Zero (opr8) - $00(HX) - $00(opr8+HX) - $00(opr8+SP) - $00 (DIR) 8 bit direct(IX) indexed no offset(IX1) indexed 8 bit offset(SP1) SP with 8 bit offset

  • 2. Instrucciones Lgicas

  • COMXComplemento a uno de XX = $FF - X(INH) inherent addressingEOR #opr8 EOR opr8EOR opr16EOR ,XEOR opr8,XEOR opr16,XEOR opr8,SPEOR opr16,SPOR Exclusiva entre Acumulador y MemoriaA = A opr8A = A (opr8)A = A (opr16)A = A (HX)A = A (opr8+ HX)A = A (opr16+ HX)A = A (opr8+ SP)A = A (opr16+ SP)(IMM) 8 bit immediate(DIR) 8 bit direct(EXT) 16 bit extended(IX) indexed no offset(IX1) indexed, 8 bit offset(IX2) indexed, 16 bit offset(SP1) SP with 8 bit offset(SP2) SP with 16 bit offsetLSL opr8LSL ,X LSL opr8,XLSL opr8,SPCorrimiento Lgico a la Izquierda C (opr8) 0C (HX) 0C (opr8+ HX) 0C (opr8+ SP) 0(DIR) 8 bit direct(IX) indexed no offset(IX1) indexed, 8 bit offset(SP1) SP with 8 bit offsetLSLACorrimiento Lgico a la Izquierda de AC A 0(INH) inherent addressingLSLX Corrimiento Lgico a la Izquierda de XC X 0(INH) inherent addressingLSR opr8 LSR ,XLSR opr8,X LSR opr8,SPCorrimiento Lgico a la Derecha0 (opr8) C0 (HX) C0 (opr8+HX) C0 (opr8+SP) C(DIR) 8 bit direct(IX) indexed no offset(IX1) indexed, 8 bit offset(SP1) SP with 8 bit offsetLSRA Corrimiento Lgico a la Derecha de A0 A C(INH) inherent addressingLSRX Corrimiento Lgico a la Derecha de X0 X C(INH) inherent addressing

  • NEG opr8 NEG ,X NEG opr8,X NEG opr8,SPComplemento a Dos(opr8) = $00 - (opr8)(HX) = $00 - (HX)(opr8+HX) = $00- (opr8+HX)(opr8+SP)=$00-(opr8+SP)(DIR) 8 bit direct(IX) indexed no offset(IX1) indexed,8 bit offset(SP1) SP with 8 bit offsetNEGAComplemento a Dos de AA = $00 A(INH) inherent addressingNEGXComplemento a Dos de XX = $00 X(INH) inherent addressingORA #opr8 ORA opr8ORA opr16ORA ,XORA opr8,XORA opr16,X ORA opr8,SPORA opr16,SPOR entre Acumulador y MemoriaA = A or opr8A = A or (opr8)A = A or (opr16)A = A or (HX)A = A or (opr8+HX)A = A or (opr16+HX)A = A or (opr8+SP)A = A or (opr16+SP)(IMM) 8 bit immediate(DIR) 8 bit direct(EXT) 16 bit extended(IX) indexed no offset(IX1) indexed/8 bit offset(IX2) indexed/16 bit offset(SP1) SP with 8 bit offset(SP2) SP with 16 bit offsetROL opr8ROL ,X ROL opr8,XROL opr8,SP Rotacin a la izquierda a travs del AcarreoC (opr8) CC (HX) CC (opr8+ HX) C C (opr8+ SP) C(DIR) 8 bit direct(IX) indexed no offset(IX1) indexed 8 bit offset(SP1) SP with 8 bit offsetROLARotacin a la izquierda del Acumulador a travs del AcarreoC A C(INH) inherent addressingROLX Rotacin a la izquierda de X a travs del AcarreoC X C(INH) inherent addressing

  • ROR opr8ROR ,X ROR opr8,XROR opr8,SPRotacin a la derecha a travs del AcarreoC (opr8) CC (HX) CC (opr8+ HX) C C (opr8+ SP) C(DIR) 8 bit direct(IX) indexed no offset(IX1) indexed 8 bit offset(SP1) SP with 8 bit offsetRORARotacin a la derecha del Acumulador a travs del AcarreoC A C(INH) inherent addressingRORXRotacin a la derecha de X a travs del AcarreoC X C(INH) inherent addressing

  • 3. Instrucciones de transferencia de datos

  • LDX #opr8LDX opr8LDX opr16LDX ,XLDX opr8,XLDX opr16,X LDX opr8,SPLDX opr16,SP Cargar XX = opr8X = (opr8)X = (opr16)X = (HX)X = (opr8+ HX)X = (opr16+ HX)X = (opr8+ SP)X = (opr16+ SP)(IMM) 8 bit immediate(DIR) 8 bit direct(EXT) 16 bit extended(IX) indexed no offset(IX1) indexed, 8 bit offset(IX2) indexed, 16 bit offset(SP1) SP with 8 bit offset(SP2) SP with 16 bit offsetMOV #opr8_1,opr8_2 MOV opr8_1,opr8_2MOV X+,opr8

    MOV opr8,X+Mover Byte(opr8_1) = opr8_2

    (opr8_2) = (opr8_1)

    (opr8) = (HX) HX = HX + 1(HX) = (opr8)HX = HX + 1 (IMD) immediate-direct

    (DD) direct to direct

    (IX+D) indexed to direct with post increment(DIX+) direct to indexed with post increment PSHA Guardar el Acumulador de la pilaPush A to stack SP = SP - 1(INH) inherent addressingPSHH Guardar H en la pilaPush H to stackSP = SP - 1(INH) inherent addressingPSHXGuardar X en la pilaPush X to stackSP = SP - 1(INH) inherent addressingPULASacar Acumulador de la pilaSP = SP + 1Pull A(INH) inherent addressing

  • PULH Sacar H de la pilaSP = SP + 1 Pull H(INH) inherent addressingPULXSacar X de la pilaSP = SP + 1Pull X(INH) inherent addressingRSPInicializar SPSPL = $FF(INH) inherent addressingSTA opr8STA opr16 STA ,XSTA opr8,X STA opr16,XSTA opr8,SP STA opr16,SPAlmacenar Acumulador en Memoria(opr8) = A(opr16) = A(HX) = A(opr8+ HX) = A(opr16+ HX) = A(opr8+ SP) = A(opr16+ SP) = A(DIR) 8 bit direct(EXT) 16 bit extended(IX) indexed no offset(IX1) indexed, 8 bit offset(IX2) indexed, 16 bit offset(SP1) SP with 8 bit offset(SP2) SP with 16 bit offsetSTHX opr8Almacenar H:X en Memoria(opr8:opr8+1) = HX(INH) inherent addressingSTX opr8 STX opr16STX ,XSTX opr8,XSTX opr16,X STX opr8,SPSTX opr16,SPAlmacenar X en Memoria(opr8) = X(opr16) = X(HX) = X(opr8+ HX) = X(opr16+ HX) = X(opr8+ SP) = X(opr16+ SP) = X(DIR) 8 bit direct (EXT) 16 bit extended(IX) indexed no offset(IX1) indexed, 8 bit offset(IX2) indexed, 16 bit offset(SP1) SP with 8 bit offset(SP2) SP with 16 bit offsetTAP Transfer Accumulator to CCRCCR = A(INH) inherent addressing

  • TAXTransfer Accumulator to Index Register XX = A(INH) inherent addressingTPATransfer CCR to AccumulatorA = CCR(INH) inherent addressingTSX Transfer Stack Pointer to Index Register H:XH:X = SPH:SPL(INH) inherent addressingTXATransfer Index Register X to AccumulatorA = X(INH) inherent addressingTXS Tansfer Index Register H:X to Stack PointerSPH:SPL = H:X(INH) inherent addressing

  • 4. Instrucciones de Salto4.1 Saltos Incondicionales

  • 4.2 Saltos Condicionales (Bifurcaciones)

    BCC relBifurcar si Acarreo = 0If C = 0 then BranchBranch = PC + 2 + rel(REL) relative addressingBCS rel Bifurcar si Acarreo = 1 If C = 1 then Branch Branch = PC + 2 + rel(REL) relative addressingBEQ relBifurcar si es igualIf Z = 1 then Branch Branch = PC + 2 + rel(REL) relative addressingBGE relBifurcar si es (operandos con signo)If (N V) = 0 then BranchBranch = PC + 2 + rel(REL) relative addressingBGT relBifurcar si es > (operandos con signo)If (Z & (N V)) = 0 then BranchBranch = PC + 2 + rel(REL) relative addressingBHCC relBifurcar si Acarreo Intermedio = 0If H = 0 then BranchBranch = PC + 2 + rel(REL) relative addressingBHCS relBifurcar si Acarreo Intermedio = 1If H = 1 then BranchBranch = PC + 2 + rel(REL) relative addressingBHI relBifurcar si est por encimaIf (C & Z) = 0 then BranchBranch = PC + 2 + rel(REL) relative addressingBHS relBifurcar si esta por encima o es igualIf C = 0 then BranchBranch = PC + 2 + rel(REL) relative addressing

  • BIH rel Bifurcar si Pin IRQ = 1If IRQ = 1 then Branch Branch = PC + 2 + rel(REL) relative addressingBIL relBifurcar si Pin IRQ = 0If IRQ = 0 then BranchBranch = PC + 2 + rel(REL) relative addressingBLE relBifurcar si es (operandos con signo)If (Z & (N V)) = 1 then BranchBranch = PC + 2 + rel(REL) relative addressingBLO relBifurcar si est por debajoIf C = 1 then BranchBranch = PC + 2 + rel(REL) relative addressingBLS relBifurcar si esta por debajo o es igualIf (C & Z) = 1 then BranchBranch = PC + 2 + rel(REL) relative addressingBLT relBifurcar si es < (operandos con signo)If (N V) = 1 then BranchBranch = PC + 2 + rel(REL) relative addressingBMC relBifurcar si Mscara de Interrupcin = 0If I = 0 then BranchBranch = PC + 2 + rel(REL) relative addressingBMI relBifurcar si negativoIf N = 1 then Branch Branch = PC + 2 + rel(REL) relative addressingBMS relBifurcar si Mscara de Interrupcin = 1If I = 1 then BranchBranch = PC + 2 + rel(REL) relative addressingBNE relBifurcar si no es igualIf Z = 0 then BranchBranch = PC + 2 + rel(REL) relative addressing

  • BPL relBifurcar si es positivoIf N = 0 then Branch Branch = PC + 2 + rel(REL) relative addressingBRA rel Bifurcar SiemprePC = PC + 2 + rel(REL) relative addressingBRCLR n,opr8,relBifurcar si Bit n en Memoria = 0If Mn = 0 then BranchBranch = PC + 3 + rel(DIR) 1 bit Direct BRN relNunca bifurcarPC = PC + 2(REL) relative addressingBRSET n,opr8,relBifurcar si Bit n en Memoria = 1If Mn = 1 then BranchBranch = PC + 3 + rel(DIR) 1 bit Direct

  • 4.3 Saltos Especiales

    CBEQ opr8,relCBEQ X+,relCBEQ opr8,X+,rel CBEQ opr8,SP,rel Compara y salta si es Igual If A- (opr8) = 0 then BranchBranch = PC + 3 + relIf A - (HX) = 0 then BranchBranch = PC + 2 + relHX = HX + 1If A - (opr8 + HX) = 0 then BranchBranch = PC + 2 + relHX = HX + 1If A - (opr8 + SP) = 0 then BranchBranch = PC + 4 + rel (DIR) 8 Bit Direct(IX+) indexed with postincrement(IX1+) indexed, 8 bit offset with post increment(SP1) Stack with 8 bit offset CBEQA #opr8,relCompara con el valor inmediato y salta si es IgualIf A - opr8 = 0 then BranchBranch = PC + 3 + rel(IMM) 8 Bit ImmediateCBEQX #opr8,relCompara con el valor inmediato y salta si es IgualIf X - opr8 = 0 then BranchBranch = PC + 3 + rel(IMM) 8 Bit Immediate

  • DBNZ opr8,relDBNZ X,relDBNZ opr8,X,relDBNZ opr8,SP,relDecrementar y bifurcar si 0(opr8) = (opr8) 1If (opr8) 0 then BranchBranch = PC + 3 + rel(HX) = (HX) 1If (HX) 0 then BranchBranch = PC + 3 + rel(opr8+HX) = (opr8+HX) 1If (opr8+HX) 0 then BranchBranch = PC + 4 + rel(opr8+SP) = (opr8+SP) - 1If (opr8+SP) 0 then BranchBranch = PC + 4 + rel (DIR) direct mode(IX) indexed, no offset(IX1) indexed,8-bit offset(SP1) SP , 8-bit offset DBNZA relDecrementar el Acumulador y bifurcar si 0A = A - 1If A 0 then BranchBranch = PC + 2 + rel(INH) inherent modeDBNZX relDecrementar X y bifurcar si 0X = X 1If X 0 then BranchBranch = PC + 2 + rel(INH) inherent mode

  • 5. Instrucciones de llamado y retorno de subrutinas

  • 6. Instrucciones a nivel de bit

  • 7. Otras instrucciones