This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

User-defined function in uVision5

Hi everyone,

I have an assembly code that I want to run in uVision4.

The .a51 code is as follows:

        MOV A, #002H
        MOV     R0,  #040H
        MOV 040H, #001H
        XCH     A, @R0

        MOV     R0,  #050H
        MOV     050H, #0F0H
        XCH     A, @R0

        MOV     R1,  #060H
        MOV     060H, #0FFH
        MOV     A, #0A0H
        XCH A, @R1


        DB      0A5H
        END

When I run the code using the debugger in uVision4, it works properly and I can either step through the instructions and see the result on the registers and memory addresses, or run the whole program and see the final result. I can also use the uVision4 built-in debug functions to do the same.

The problem arises though, when I want to do the same stepping in my code, using some user-defined functions.

Here are my scripts and functions:

include tb_run_instructions.ini
include test_instr_xch_a_at_ri.ini

Func void test_instr(void)
{
        test_instr_xch_a_at_ri();
        return;
}
Func void test_instr_xch_a_at_ri(void)
{
        exec ("T 4");
        tb_run_instructions(4);
        exec ("T 3");
        tb_run_instructions(3);
        exec ("T 4");
        tb_run_instructions(4);
        return;

}
Func void tb_run_instructions(int inst)
{
        printf("%d instructions were executed\n", inst);
        return;
}

I run my code as:

In the command line of uVision I first include the main function, which includes the other required functions

include test_instr.ini

Then I run this function, which in turns run the other functions using

test_instr()

The problem is that only the first exec line in my function runs and the second and third execs shown in test_instr_xch_a_at_ri, do not run.
Interestingly all the tb_run_instructions functions run and print their messages.

The final output in the command window of uVision4 is:

4 instructions were executed
3 instructions were executed
4 instructions were executed

But only the first four instructions were executed, and nothing happened afterwards.

Can you please help me to find out, where the problem is and how I can fix this, to run all required exec ("T x") in my script?

Cheers,
Mostafa

0