how to declare a global variable in assembly code with 56f8367

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to declare a global variable in assembly code with 56f8367

2,949件の閲覧回数
Gaoya
Contributor I

hello,

I am using EVM8367 now, can somebody tell me how to declare a global variable in assembly code with  56f8367 and this variable can also be used in C ? thank you very much.

ラベル(1)
0 件の賞賛
2 返答(返信)

1,384件の閲覧回数
CrasyCat
Specialist III

Hello

 

Assembler directives that can be used to create global variables are described in the 56800x_Assembler.pdf manual.

 

For instance you can define a buffer as follows:

 

    org x:
    GLOBAL F_S_BUF
F_S_BUF DS 12 ; 12-byte buffer

 

The GLOBAL directive instruct the assembler that the symbol needs to be visible from outside of the assembler module where it is declared. The F prefix is added in front of each global symbol by the compiler and is needed here as you intend to access the variable from ANSI C.

 

ANSI C declaration and access can be done as follows:

extern char _S_BUF[12];

int main(void) {
   _S_BUF[1] = 1;
   /* Your code here */
}

 

 

 

CrasyCat

0 件の賞賛

1,384件の閲覧回数
CrasyCat
Specialist III
This discussion was moved to a better location.
0 件の賞賛