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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

2,914 次查看
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,349 次查看
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,349 次查看
CrasyCat
Specialist III
This discussion was moved to a better location.
0 项奖励