公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

Tip / 登入 to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Weeden_ding
Level 2
Level 2
Distributor - Weikeng(GC)
25 sign-ins 5 replies posted 10 questions asked

Hi,

   CLASSB  认证中有 RAM_TEST文件是asm文件,

问题:1》里面的_Ramtest 函数请问如何在主程序C语言中调用?

2》 Start address ,End address 参数如何传入?

谢谢!

_Ramtest:

/* Tested RAM area:0090H~047FH,use checkboard arithmetic which write alternate "0" and

"1" to memory, verify if the write data is right by reading back the data written

Start address -> IX

End address -> EP */

L_Next: MOV A, #0X55

MOV @IX, A

CMP @IX, #0X55

BNZ ram_error

MOV A, #0XAA

MOV @IX, A

CMP @IX, #0XAA

BNZ ram_error

MOV A, #0X00

MOV @IX, A

CMP @IX, #0X00 // clear the tested ram area

BNZ ram_error

INCW IX

MOVW A, IX

MOVW A, #0X0000 // MOV IX value to T register

MOVW A, EP

CMPW A // check if the address is equal to the end address

BNZ L_Next // if the address is not equal to the end address, it will jump to test next byte

// if the address is equal to the end address, it will clear all tested RAM area

RET

/*once RAM test error is detected, program will run into an infinite loop.*/

ram_error:

JMP ram_error

RET

0 点赞
1 解答
Amy_Qian
Employee
Employee
5 sign-ins 10 solutions authored 10 replies posted

Hi,

C中调用汇编部分程序你可以参考下面这样使用

unsigned int address;

void test(unsigned int Address)

{

     address = Address;

#pragma asm

     PUSHW    IX

     PUSHW    A

     MOVW     A, EP

     PUSHW    A

    

     MOVW     A, _address

     MOVW     EP,A

     CALL     _RAMTEST

    

     POPW     A

     POPW     IX

    

#pragma endasm

}

汇编这边需要存地址

_RAMTEST:

          MOVW     A,EP

          PUSHW     A         

在原帖中查看解决方案

0 点赞
2 回复数
Roy_Liu
Moderator
Moderator
Moderator
First comment on KBA 10 questions asked First comment on blog

Hi,

Please refer to the Softune compiler manual - https://www.cypress.com/file/250876/download

Roy Liu
0 点赞
Amy_Qian
Employee
Employee
5 sign-ins 10 solutions authored 10 replies posted

Hi,

C中调用汇编部分程序你可以参考下面这样使用

unsigned int address;

void test(unsigned int Address)

{

     address = Address;

#pragma asm

     PUSHW    IX

     PUSHW    A

     MOVW     A, EP

     PUSHW    A

    

     MOVW     A, _address

     MOVW     EP,A

     CALL     _RAMTEST

    

     POPW     A

     POPW     IX

    

#pragma endasm

}

汇编这边需要存地址

_RAMTEST:

          MOVW     A,EP

          PUSHW     A         

0 点赞