CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Help in inserting ASM code into C code

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gai_man_de



Joined: 18 Apr 2010
Posts: 1

View user's profile Send private message

Help in inserting ASM code into C code
PostPosted: Sun Apr 18, 2010 6:13 am     Reply with quote

I'm trying to insert assembly code into C code in CCS that make LEDs blink 3 times. But there are 2 errors:
1. Expecting an opcode mnemoric Delay100ms;
2. Undefined label that use in a GOTO > main1
Can anyone help me to fix it?
Code:

#include <16f877a.h>
#device *=16 ADC=8
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP
#use delay(clock=4000000)

int temp=3;
int delay_reg1;
int delay_reg2;

void main()
{
   #asm
   goto main1
Delay100ms
   MOVLW 0x83
   MOVWF delay_reg1
   MOVLW 0xFF
   MOVWF delay_reg2
loop1
   DECFSZ delay_reg1
   GOTO loop2
   GOTO exit
loop2
   DECFSZ delay_reg2
   GOTO loop2
   GOTO loop1
Exit
   RETURN
 
   main1
   banksel TRISB
   clrf    TRISB
   banksel PORTB
loop
   clrf    PORTB
   call    Delay100ms
   movlw   0xff
   movwf   PORTB
   call    Delay100ms
   decfsz  temp,f
   goto    loop
   #endasm
 while(1);
 }     
 
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Apr 18, 2010 7:37 am     Reply with quote

Obvious error: labels should end with a ':' character. For example 'loop1' should be changed to 'loop1:'

But why would you use a C-compiler to write assembly? You are using the wrong tool for the job. Assembly is old and out of fashion, but if you need to use it then use the free Microchip Assembler which has much better support for writing assembly.

Still, writing your program in C gets you a working program faster, with less effort and easier to maintain.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group