anhnha
Full Member level 6
Hi all,
I am programming to convert a c code section into assembly .This is may c code:
and here is my ammsembly code:
When i build and run it in proteus then is only the unit of temperature display, it can not display the tens.I had try to find how compiler CCS compile it but i don't understand why i can't display the tens of temperature.Would you give the explaination of that is wrong in this code?
Thank you.
I am programming to convert a c code section into assembly .This is may c code:
Code:
// display temperature in led
if(kt2==1) //
{ //
output_c(0x01); //
output_b(maled[t/10]); // display tens
} //
else //
{ //
output_c(0x02); //
output_b(maled[t%10]); // display units
}
Code:
#include <16f877a.h>
#device *=16 ADC=10
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#use fast_io(e)
#use i2c(Master,sda=PIN_C4,scl=PIN_C3)
#use delay(clock=20000000)
#include <lcd.c>
#bit set_ra5= 0x85.5
#byte PORTB = 0x06
#byte TRISB = 0x86
#byte PORTC = 0x07
#byte TRISC = 0x87
#if kt2==1
#byte temp_add = 0x4C
#else
#byte temp_add = 0x4D
// led code
int8 maled[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
#asm
MOVLW 0x00
MOVWF TRISB ;set portb is output
MOVLW 0x18
MOVWF TRISC ; set for portc
DECFSZ 0x4F, 1 ; check condition kt2==1 or not
GOTO chuc ; go to display tens of temperature
BSF PORTC, 1
GOTO display
chuc:
BSF PORTC, 0
GOTO display ; display units of temperature
display:
BCF 0x03, 5
MOVF temp_add, 0
XORLW 0x00
BTFSC 0x03,2
GOTO zero
MOVF temp_add, 0
XORLW 0x01
BTFSC 0x03,2
GOTO one
MOVF temp_add, 0
XORLW 0x02
BTFSC 0x03,2
GOTO two
MOVF temp_add, 0
XORLW 0x03
BTFSC 0x03,2
GOTO three
MOVF temp_add, 0
XORLW 0x04
BTFSC 0x03,2
GOTO four
MOVF temp_add, 0
XORLW 0x05
BTFSC 0x03,2
GOTO five
MOVF temp_add, 0
XORLW 0x06
BTFSC 0x03,2
GOTO six
MOVF temp_add, 0
XORLW 0x07
BTFSC 0x03,2
GOTO seven
MOVF temp_add, 0
XORLW 0x08
BTFSC 0x03,2
GOTO eight
MOVF temp_add, 0
XORLW 0x09
BTFSC 0x03,2
GOTO nine
GOTO end_1
zero: MOVLW 0xC0
MOVWF PORTB
GOTO end_1
one: MOVLW 0xF9
MOVWF PORTB
GOTO end_1
two: MOVLW 0xA4
MOVWF PORTB
GOTO end_1
three: MOVLW 0xB0
MOVWF PORTB
GOTO end_1
four: MOVLW 0x99
MOVWF PORTB
GOTO end_1
five: MOVLW 0x92
MOVWF PORTB
GOTO end_1
six: MOVLW 0x82
MOVWF PORTB
GOTO end_1
seven: MOVLW 0xF8
MOVWF PORTB
GOTO end_1
eight: MOVLW 0x80
MOVWF PORTB
GOTO end_1
nine: MOVLW 0x90
MOVWF PORTB
GOTO end_1
end_1:
#endasm
Thank you.