我要实现的功能就是从程序区的0x7000处读取16位数据出来,函数如下
void get_program(unsigned short *src)
{
asm(" LACC #28672 ");
asm(" TBLR *,AR4 ");
}
数据是读出来了但函数返回的时跳到其它地方了
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我要实现的功能就是从程序区的0x7000处读取16位数据出来,函数如下
void get_program(unsigned short *src)
{
asm(" LACC #28672 ");
asm(" TBLR *,AR4 ");
}
数据是读出来了但函数返回的时跳到其它地方了
貌似在2407里数据区和程序区不是统一编址的,用指针读的是ram的数据,不知道是不是要加什么修饰符号。
不过我仔细看了一下汇编搞定了:
void get_program(unsigned short *dst)
{
asm(" LACK 28672");
asm(" MAR *,AR4");
asm(" TBLR *,AR1");
}
dst是局部变量的指针,会通过AR4传递。
LACK #28672是设置要访问的程序区地址,
MAR *,AR4是设置AR4为当前AR
TBLR *,AR1的作用是以ACC的低16位作为程序区地址 读取程序区数据到当前AR所指的数据区中 然后设置AR1为当前AR。
看C汇编后的代码在执行我的内嵌汇编前AR1是当前AR,因此我更改当前AR后再还原回去。
用下面这个函数彻底解决了这个问题
void get_program(unsigned long src, unsigned short *dst)
{
asm(" SBRK #6");
asm(" LAR AR4,*,AR4");
asm(" TBLR *,AR1");
asm(" ADRK #6");
}