dannyelloko20
Newbie level 5
- Joined
- Mar 25, 2015
- Messages
- 9
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 65
I need to sum and subtract two hex values as it is shown in my code below. However, when I export the hex file to Pickit2 and then to my board, it will not go to SUM for some reason. Can you guys give me a hint as to why this is not working?
Thank you!
Thank you!
Code:
***********************************************************************
#include <GENERAL.H>
; ================ EQUATES =========================================
NUM1 EQU 0x5A
NUM2 EQU 0x39
REG1 EQU 0x40
REG2 EQU 0x41
; =======================================================================
__CONFIG 0X3FF2 ;This is the control bits for CONFIG register
ORG 0X0000 ;RESET or WDT reset vector
GOTO START
ORG 0X0004 ;Regular INT vector RESERVE THIS SPACE. DON'T USE IT
RETFIE
START
CLRW
BSF STATUS,RP0
MOVWF TRISB
BCF STATUS,RP0
MOVWF PORTB
BTFSC PORTA,0 ;skip next instruction if RA0 = 0 and go to SUM
GOTO SUM
CLRW
MOVLW NUM2 ;put NUM2 in W
SUBLW NUM1 ;subtract NUM2 in W from NUM1
MOVWF REG1 ;save the result in REG1
MOVF STATUS,W ;copy the STATUS register value to W (not necessary but requested by professor)
MOVWF REG2 ;and then to REG2 (not necessary but requested by professor)
MOVWF PORTB
GOTO DONE
SUM
CLRW
MOVLW NUM1 ;put NUM1 in W
ADDLW NUM2 ;add NUM2 with the result in W
MOVWF REG1 ;save the result in REG1
MOVF STATUS,W ;copy the STATUS register value to W
MOVWF REG2 ;and then to REG2
MOVWF PORTB
DONE
END