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

Legacy microcontrollers Forum Discussions

Weeden_ding
Level 2
Level 2
10 questions asked 10 sign-ins 5 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 Likes
1 Solution
Amy_Qian
Employee
Employee
10 solutions authored 10 replies posted 5 solutions authored

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         

View solution in original post

0 Likes
2 Replies
Roy_Liu
Moderator
Moderator
Moderator
1000 replies posted 500 solutions authored 5 questions asked

Hi,

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

Roy Liu
0 Likes
Amy_Qian
Employee
Employee
10 solutions authored 10 replies posted 5 solutions authored

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 Likes