Read Accumulator Register from C

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

Read Accumulator Register from C

Jump to solution
3,399 Views
jimw
Contributor II
Is there a simple efficient way to move the contents of Reg A to a variable in C?
 
 
 
Labels (1)
Tags (1)
0 Kudos
1 Solution
647 Views
jimw
Contributor II
I think I found it.
 
char t;
 __asm {
 sta t
 }
 
compiles as:
 
  TSX
  STA ,X
 
 
 

View solution in original post

0 Kudos
2 Replies
647 Views
bigmac
Specialist III
Hello JimW,
 
Whenever a function returns a char value, the returned value will be in the accumulator.  So the following seems to work OK.
 
char funcA(void) {
  asm lda TCNTL;   /* Low byte of timer reg */
}
 
 
char value;
 
value = funcA();
 
Regards,
Mac
 
648 Views
jimw
Contributor II
I think I found it.
 
char t;
 __asm {
 sta t
 }
 
compiles as:
 
  TSX
  STA ,X
 
 
 
0 Kudos