2 Replies Latest reply on Oct 26, 2020 3:18 AM by MinQ_41

    汇编函数调用

    DIWE_3890046

      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