dannyelloko20
Newbie level 5
- Joined
- Mar 25, 2015
- Messages
- 9
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 65
Hi everyone, Im new here so bear with me. I have a project Im working on and kinda need some help. This is pretty much what has to be done: Write an Assembly program using MPLAB IDE and “Project Wizard” that will read binary switch S10 from PORTA and if this value is logic “0”, add the following two Hex Numbers (NUM1 + NUM2) and store the sum in REG1 and the STATUS register in REG2. If S10 is logic “1”, store the difference (NUM1 - NUM2) in REG1 and the STATUS register in REG2. NUM1 = 0x5A and NUM2 = 0x39
This is what I came up with:
I need some help debugging this code. Im stuck here and I dont know whats wrong.
Thanks
This is what I came up with:
Code:
NUM1 EQU 0X5A
NUM2 EQU 0X39
REG1 EQU 0X40
REG2 EQU 0X41
ORG 0X00
START BSF STATUS,RP0
MOVWF TRISB
BCF STATUS,RP0
MOVWF PORTB
CLRF PORTA
CLRF PORTB
MOVLW 0X5A
MOVWF NUM1
CLRW
MOVLW 0X39
MOVWF NUM2
BTFSS PORTA,1
GOTO SUB
MOVWF NUM1
ADDWF NUM2
MOVF REG1
MOVWF PORTB
SUB MOVWF NUM1
SUBWF NUM2
MOVF REG1
END
I need some help debugging this code. Im stuck here and I dont know whats wrong.
Thanks