Author Topic: asembler  (Read 1656 times)

0 Members and 1 Guest are viewing this topic.

Offline RoboMoonTopic starter

  • Jr. Member
  • **
  • Posts: 19
  • Helpful? 0
asembler
« on: July 17, 2010, 11:08:30 AM »
I want to understand what this file does



LIST P=16F84, F=INHX8M
include "P16FXX.inc"
ORG 0x0000

GOTO Label_0001
NOP
NOP
NOP
RETFIE
Label_0001 BCF STATUS , RP0
BCF STATUS , RP1
CLRF PORTA
CLRF PORTB
BSF STATUS , RP0
MOVLW 0x06
MOVWF 0x1F
MOVLW 0x00
MOVWF TRISA
MOVLW 0xF0
MOVWF TRISB
MOVLW 0x00
MOVWF OPTION_REG
BCF STATUS , RP0
MOVLW 0x03
MOVWF 0x20
MOVLW 0x06
MOVWF 0x21
MOVLW 0x05
MOVWF 0x22
BCF 0x23 , 00
MOVLW 0x01
MOVWF 0x24
Label_0010 BCF 0x23 , 01
BCF PORTA , 02
BSF PORTA , 00
MOVF 0x20 , W
MOVWF PORTB
CALL Label_0002
MOVF PORTB , W
BTFSC PORTB , 04
GOTO Label_0003
MOVLW 0x01
CALL Label_0004
GOTO Label_0005
Label_0003 BTFSC PORTB , 05
GOTO Label_0006
MOVLW 0x04
CALL Label_0004
GOTO Label_0005
Label_0006 BTFSC PORTB , 06
GOTO Label_0007
MOVLW 0x07
CALL Label_0004
GOTO Label_0005
Label_0007 BTFSC PORTB , 07
GOTO Label_0005
MOVLW 0xF0
CALL Label_0004
Label_0005 BCF PORTA , 00
BSF PORTA , 01
MOVF 0x21 , W
MOVWF PORTB
CALL Label_0002
MOVF PORTB , W
BTFSC PORTB , 04
GOTO Label_0008
MOVLW 0x02
CALL Label_0004
GOTO Label_0009
Label_0008 BTFSC PORTB , 05
GOTO Label_000A
MOVLW 0x05
CALL Label_0004
GOTO Label_0009
Label_000A BTFSC PORTB , 06
GOTO Label_000B
MOVLW 0x08
CALL Label_0004
GOTO Label_0009
Label_000B BTFSC PORTB , 07
GOTO Label_0009
MOVLW 0x00
CALL Label_0004
Label_0009 BCF PORTA , 01
BSF PORTA , 02
MOVF 0x22 , W
MOVWF PORTB
CALL Label_0002
MOVF PORTB , W
BTFSC PORTB , 04
GOTO Label_000C
MOVLW 0x03
CALL Label_0004
GOTO Label_000D
Label_000C BTFSC PORTB , 05
GOTO Label_000E
MOVLW 0x06
CALL Label_0004
GOTO Label_000D
Label_000E BTFSC PORTB , 06
GOTO Label_000F
MOVLW 0x09
CALL Label_0004
GOTO Label_000D
Label_000F BTFSC PORTB , 07
GOTO Label_000D
MOVLW 0xFF
CALL Label_0004
Label_000D BCF PORTA , 02
BTFSS 0x23 , 01
BCF 0x23 , 00
GOTO Label_0010
Label_0004 BTFSC 0x23 , 00
GOTO Label_0011
MOVWF 0x26
BTFSC 0x26 , 07
GOTO Label_0012
BTFSS 0x24 , 00
GOTO Label_0013
MOVWF 0x20
BCF 0x24 , 00
BSF 0x24 , 01
GOTO Label_0011
Label_0013 BTFSS 0x24 , 01
GOTO Label_0014
MOVWF 0x21
BCF 0x24 , 01
BSF 0x24 , 02
GOTO Label_0011
Label_0014 BTFSS 0x24 , 02
GOTO Label_0015
MOVWF 0x22
BCF 0x24 , 02
BSF 0x24 , 00
GOTO Label_0011
Label_0015 BTFSS 0x24 , 03
GOTO Label_0011
GOTO Label_0011
Label_0012 NOP
Label_0011 BSF 0x23 , 00
BSF 0x23 , 01
RETURN
MOVLW 0x03
MOVWF 0x2F
Label_0016 DECFSZ 0x2F , f
GOTO Label_0016
RETURN
MOVLW 0x66
MOVWF 0x20
Label_0017 DECFSZ 0x20 , f
GOTO Label_0017
NOP
RETURN
Label_0002 MOVLW 0xFF
MOVWF 0x2E
Label_0019 MOVLW 0xFF
MOVWF 0x2F
Label_0018 DECFSZ 0x2F , f
GOTO Label_0018
DECFSZ 0x2E , f
GOTO Label_0019
RETURN

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: asembler
« Reply #1 on: July 17, 2010, 01:07:06 PM »
Go to Microchips web site and download the Data sheet for the PIC16F84. In the data sheet is the Assembler instructions used on that PIC. Go through the code you have and look up each instruction for what it does.

Secondly, download and install MPLAB from Microchip. Create a project and just that code for the source. Then use the MPLAB SIMulator to step through the code and look at the registers and ports to see what the code is doing.

The 16F84 is not that complex of a PIC and with a little time to study you can figure out what that code does yourself.