You are on page 1of 9

Hense Technology

AN1234

HENSE TECHNOLOGY

Application Note

Converting PIC to Freescale (Motorola) HC08 Assembler

AN1234e

10/2004

2004 Hense Technology Ltd.

AN 1234 - 1/9

Hense Technology e

AN1234

HC908 Instructions & PIC Equivalents


Operations Microchip Instruction(s) Bytes Freescale HC908 Instruction Byte

Byte-Orientede file register operations


Add W and f AND W with f Clear f Clear W Complement f ADDWF ANDWF CLRF CLRW COMF 2 2 2 2 3 ADD AND CLC CLI CLR COM COMA COMX Decrement f Decrement f, Skip if 0 Increment f Increment f, Skip if 0 Inclusive OR W with f Move f Move W to f No Operation Rotate Left f through Carry DECF DECFSZ INCF INCFSZ IORWF MOVF MOVWF NOP RLF 2 2 2 1 2 4 2 2 2 DEC No equivalent instruction INC No equivalent instruction ORA MOV MOV NOP ROL ROLA ROLX Rotate Right through Carry RRF 2 ROR RORA RORX Subtract W from f Swap nibbles in f Exclusive OR W with f SUBWF SWAPF XORWF 2 2 2 SUB NSA EOR 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2

Bit Oriented file register operations


Bit Clear f Bit Set f Bit test f, Skip if Clear Bit test f, Skip if Set BCF BSF BTFSC BTFSS 2 2 4 4 BCLR BSET BRCLR BRSET 2 2 3 3

2004 Hense Technology Ltd.

AN 1234 - 2/9

Hense Technology

AN1234

HC908 Instructions & PIC Equivalents


Operations Microchip Instruction(s) ADDLW ANDLW CALL CLRWDT GOTO IORLW MOVLW RETFIE RETLW RETURN SLEEP SUBLW XORLW Bytes 2 2 2 2 2 2 2 2 2 2 2 2 2 Freescale HC908 Instruction Byte ADD AND BSR No equivalent instruction BRA ORA MOV RTI No equivalent instruction RTS WAIT SUB EOR 1 1 2 2 2 2 2 1 2 2 2

Literal And Control Operations


Add literal and W AND literal with W Call subroutine Clear Watchdog Timer Go to address Inclusive OR literal with W Move literal to W Return from interrupt Return with literal in W Return from Subroutine Go into standby mode Subtract W from literal Exclusive OR literal with W

2004 Hense Technology Ltd.

AN 1234 - 3/9

Hense Technology

AN1234

HC908 Instructions & PIC Equivalents


Operations
Add with Carry PIC Instruction(s) BTFS STATUS, C INCF M,F ADDWF M,F Arithmetic Shift Left Arithmetic Shif Right BCF STATUS, C RLF M,F BCF STATUS,C BTFSC M,7 BSF STATUS,C RRF M,F Branch if Carry Bit Clear Branch if Carry Bit Set Branch if Equal Branch if Greater than BTFSS STATUS,C GOTO addr BTFSC STATUS,C GOT addr BTFSC STATUS,Z GOTO addr BTFSS STATUS,N BNOV rel BTFSS STATUS,OV BNN rel Branch if Half Carry Bit Clear Branch if Half Carry Bit Set Branch if Higher BTFSC STATUS,DC GOTO addr BTFSC STATUS,DC GOTO addr BTFSC STATUS,C GOTO addr BTFSC STAUTS,Z GOTO addr Branch if Higher or Same Barnch if IRQ High Branch if IRQ Low BTFSS STATUS,C GOTO addr BTFSC PORTx, <pin> GOTO addr BTFSS PORTx,<pin> GOTO addr 4 BIL 2 4 BHI 2 4 BHS 2 8 BHI 2 4 BHCS 2 4 BHCC 2 16 BGT 2 4 BEQ 2 4 BCS 2 4 BCC 3 8 ASR 3 2 ASL 3 Bytes 6 HC908 Instruction(s) ADC Bytes 3

2004 Hense Technology Ltd.

AN 1234 - 4/9

Hense Technology

AN1234

HC908 Instructions & PIC Equivalents


Operations
Bit Test Branch if Lower Branch if Lower or Same PIC Instruction(s) MOVLW <mask> ANDWF M,W BTFSC STATUS,C GOTO addr BTFSC STATUS,C GOTO addr BTFSC STATUS,Z GOTO addr Branch if IRQ Mask Clear Branch if Minus Branch if IRQ Mask Set Branch if Not Equal Branch if Plus Branch if BIT n in Memory Clear Branch if Bit n in Menory Set Compare and Branch if Equal BTFSS INTCON, GIE GOTO addr BTFSC M,7 GOTO addr BTFSC INTCON,GIE GOTO addr BTFSS STATUS,Z GOTO addr BTFSS M,7 GOTO addr BTFSS M,n GOTO addr BTFSC M,n GOTO addr SUBWF M,W BTFSC STATUS,Z GOTO addr Compare Index Register with Memory MOVF M,W SUBWF FSR,W 2 CPX 2 6 CBEQ 3 4 BRSET n 3 4 BRCLR n 3 4 BPL 2 4 BNE 2 4 BMS 2 4 BMI 2 4 BMC 2 8 BLS 2 4 BLO 2 Bytes 4 HC908 Instruction(s) BIT Bytes 3

2004 Hense Technology Ltd.

AN 1234 - 5/9

Hense Technology

AN1234

HC908 Instructions & PIC Equivalents


Operations
Decimal Adjust Accumulator PIC Instruction(s) ADDLW 0x06 BTFSS STATUS,DC GOTO $+3 ADDLW 0x10 GOTO $+2 ADDLW 0xFA GOTO $+2 ADDLW 0xFA ADDLW 0x60 BTFSS STATUS,DC ADDLW 0xA0 Decrement and Branch if Not Zero Divide Load index Register From Memory Logical Shift Left Logical Shift Right Move Multiply Negate (2'S Complement) Subtract with Carry DECF M,F BTFFSS STATUS,Z GOTO addr (Divide Routine)(AN617) MOVF M,W MOVWF FSR BCF STATUS,C RLF M,F BCF STATUS,C RRF M,F MOVF M,W MOVWF N Mulitply Routine COMF M,F INCF M,F BTFSS STATUS,C INCF M,F SUBWF M,F Store Index Register Store Index Register Low in Memory Test for Negative or Zero MOV FSR, W MOVWF M MOVF FSR,W MOVWF M MOVLW O SUBWF M,W 2 TST 1 2 STX 2 2 STHX 2 6 SBC 3 42 4 MUL NEG 1 2 4 MOV 3 4 LSR 3 4 LSL 3 82 4 DIV LDX 1 3 6 DBNZ 4 Bytes 18 HC908 Instruction(s) DAA Bytes 1

2004 Hense Technology Ltd.

AN 1234 - 6/9

Hense Technology

AN1234

HC908 Exact Instructions


Operations
Add Immediate Value to Stack Point Register Branch if Greater Than or Equal Branch if Greater Than Branch if Less than or Equal to Branch if Less than Compare index Register with memory Load Index Register From Memory Push Accumulator onto Stack No Equivalent Instruction Push Index Register High onto Stack Push Index Register Low onto Stack Pull Accumulator from Stack Pull Index Register High from Stack Pull Index Register Low from Stack Reset Stack Pointer Transfer Stack Pointer to Index Register Transfer Index Register to Stack Pointer PSHH PSHX PULA PULH PULX RSP TSX TXS 1 1 1 1 1 1 1 1 PIC Instruction(s) Bytes HC908 Instruction(s) AIS AIX BGE BGT BLE BLT CPHX LDHX PSHA Bytes 2 2 2 2 2 2 2-3 2-4 1

2004 Hense Technology Ltd.

AN 1234 - 7/9

Hense Technology

AN1234

Notes:

2004 Hense Technology Ltd.

AN 1234 - 8/9

Hense Technology

AN1234

Worldwide Sales and Service


Head Office: Singapore HQ: Blk 212 Hougang Street 21, #03-319/321, Singapore 530212 Tel: (65) 6285 9890 Fax: (65) 6285 4813 Email: sales@hensetech.com.sg Hong Kong office: Rm 1512, Chevalier Commercial Center, 8 Wang Hoi Road, Kowloon Bay, H.K. Tel: (852) 2331 3813 Fax: (852) 2331 3909 Email : sales.sc@hensetech.com.hk Shanghai office: Rm A1108,Yin Hai Commercial Bldg, No.250 Cao Xi Road, Shanghai, China. Postal Code:200235 Tel: (86) 021-6482 4682 Fax: (86) 021-6482 4680 Email: sales.nc@hensetech.com.hk Shenzhen office: Rm E1, 17/F, Cooperative Finance Bldg, No.3038 Shennan Road East, Shenzhen P.R. China. Postal Code: 518001 Tel: (86) 755-2518 8082 Fax: (86) 755-2518 8153 Email: sales.sc@hensetech.com.hk

2004 Hense Technology Ltd.

AN 1234 - 9/9

You might also like