Hi Everyone Maybe previous a question to application external memory has confused, let me repost sample question about stack of instructions. The assembler code is push register R0,R1 onto stack and pop register R0,R1from stack. So how to write a C51 program like this function or have any instructions? PUSH 0 ; register R0 PUSH 1 ; register R1 . . . . POP 1 ; register R0 POP 0 ; register R1
I want to know that how to write a progam of C51 to push and pop R0 and R1 to and from that stack. WHY, WHY, WHY Please, oh please, answer Erik
Hi Erik I am not directly push and pop register, it's contents. I want to know that have any instructions of C51 like it or create and use a write to store data at same function? For explam: MOV R0,#00 ;1 line CALL aa ;----------- aa: PUSH 0 Mov R0,#ff ;2 line . . POP R0 RET ;----------- I want to keep 1 line register(R0) of content when excuted 2 line progeame.
Sorry! It is "POP 0"
I this example, the two 'a' are separate variables: void Func(void) { char a; a=20; } main() { char a; a=10; Func(); //Here, a still equals 10 while(1); } In this example there is only one 'a': char a; void Func(void) { a=20; } main() { a=10; Func(); //Here, a equals 20 while(1); } In this example we preserve the value of 'a': char a; void Func(void) { char b; b=a; //b equals 10 a=20; //a equals 20 a=b; //a equals 10 again } main() { a=10; Func(); //Here, a equals 10 while(1); } Does any of this make any sense to you?
Hi Hsu, I assume you are using the assembler and it is an 'asm' file that you are creating, if so, then this is what your code should be modified to allow you to push/pop R0:-
MOV R0,#00 ;1 line CALL aa ;----------- aa: PUSH AR0 ;*** MODIFIED *** Mov R0,#ff ;2 line . . POP AR0 ;*** MODIFIED *** RET ;-----------