SamanthaL
Junior Member level 2
Hello all!
Below is a subroutine that is supposed to call different things based on the value of Test_Count. What the code below should be doing is taking Test_Count (which is initialized to 3) and seeing what its value is by subtracting values from it and seeing if the output is zero. It calls Test# which does other stuff then returns. After this, it goes to Continue, where the Test_Count variable is decremented and the subroutine is called again.
The output is only calling Test4. It keeps repeating this without going through the other test cases. Am I doing something wrong with the status register?
Generate_Test_Cases_2
movf Test_Count,W
sublw b'00000011'
btfsc STATUS,Z ; if W = 3,
call Test4
movf Test_Count,W
sublw b'00000010'
btfsc STATUS,Z ; if W = 2,
call Test3
movf Test_Count,W ; W = Test_Count
sublw b'00000001' ; if W = 1;
btfsc STATUS,Z
call Test2
movf Test_Count,W ; W = Test_count
sublw b'00000000'
btfsc STATUS,Z ; if W = 0,
call Test1
bsf PORTC,7 ; MC code is 01
bcf PORTC,6 ; MC now ready to send data
call Wait
goto Continue
Continue
decfsz Test_Count ; Move on to next test case
goto Start ; Reinitialize Test_Count to 3
call Wait
goto Generate_Test_Cases_2
Below is a subroutine that is supposed to call different things based on the value of Test_Count. What the code below should be doing is taking Test_Count (which is initialized to 3) and seeing what its value is by subtracting values from it and seeing if the output is zero. It calls Test# which does other stuff then returns. After this, it goes to Continue, where the Test_Count variable is decremented and the subroutine is called again.
The output is only calling Test4. It keeps repeating this without going through the other test cases. Am I doing something wrong with the status register?
Generate_Test_Cases_2
movf Test_Count,W
sublw b'00000011'
btfsc STATUS,Z ; if W = 3,
call Test4
movf Test_Count,W
sublw b'00000010'
btfsc STATUS,Z ; if W = 2,
call Test3
movf Test_Count,W ; W = Test_Count
sublw b'00000001' ; if W = 1;
btfsc STATUS,Z
call Test2
movf Test_Count,W ; W = Test_count
sublw b'00000000'
btfsc STATUS,Z ; if W = 0,
call Test1
bsf PORTC,7 ; MC code is 01
bcf PORTC,6 ; MC now ready to send data
call Wait
goto Continue
Continue
decfsz Test_Count ; Move on to next test case
goto Start ; Reinitialize Test_Count to 3
call Wait
goto Generate_Test_Cases_2