HC08 C Beginners Guide for CodeWarrior in Variables Declaration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HC08 C Beginners Guide for CodeWarrior in Variables Declaration

3,743 Views
el_shaka
Contributor I
Hi everybody!!:smileyhappy:

Does anybody knows about a document where it explains the way of how do special Things using C and codewarrior. Ive been using MC908AP8 for quite a while using only assembler.

Now im having some problems because i do not know how to use C with Assembler, specifically with variable declarations and how to refer to an specific memory location as a variable.

Assume that i have a C code and I invoce a function in ASM. This function stores a result in, to say, $81, now i need that in my  C code, but i have no idea how to do it. Ive tried:

count = 0x81; (failed)

#define count unsigned int 0x81; (failed)

and some other ways that ive found in the Hepl and in the forum.

An example of my code is right here


void main (void)
{
   asm_code();                      // (It couts something and stores the final count in $81, it wont be over FF )
   count = ????????????; ( I want to say that count = $81)
}
 
Thanks a lot, an explanation, a link to some tutorial, a link to any manual, anything, please.
Labels (1)
0 Kudos
Reply
4 Replies

1,251 Views
el_shaka
Contributor I
Actually what i did was
count = @0x0081
 
 
Thanks a lot.
0 Kudos
Reply

1,251 Views
B_Conf
Contributor I
Hello,
       I hope that the next code give you an example and you can resolve tha task:

byte aux[3];       // This is the declaration in C

asm{                                     
      LDHX #@aux                 
  adquiere:
       lda Some_Var    
       sta ,X                   
       incx                      
       cpx #@aux+3           
       bne adquiere            
                                 
  }
    I load the direction of aux in HX, but if I´not wrong if you put @aux you 've got the value of aux[0], @aux+1 value of aux[1] and so on.
  Try this:
    mov @aux,@count or something else.

Best regards
Pablo.
0 Kudos
Reply

1,251 Views
xiefei
Contributor I
try this out
count = *(int *)0x81;
0 Kudos
Reply

1,251 Views
bigmac
Specialist III
Hello,
 
Try the following approach -
Within a .c or .h file, use the following global variable definition -
extern char count @0x0081;
 
Then near the top of the .asm file in which you will be using the variable, include the line -
  XREF  count
 
Then simply refer to the variable name as required.
 
Regards,
Mac
 
0 Kudos
Reply