Hi all! I need to read out the actuall value of the program counter (PC). How can I do that? I use the Keil uVision environment with an 8051 based controller! Thanks for your help!
Call a special subroutine that reads the return address off the stack.
I don't wanna use a "call" subroutine! I just use a "jmp" command. For having the return address I need the actual PC value. (no label).
You may not wanna calla subroutine but you're gonna hafta calla subroutine to finda outa the value of the program counta. Stefan
I am not allowed to use a "call" function because I am not allowed to alter the stack pointer (SP). Instead of using the "call" command I want to use a "jmp". Before I perform the jump command I need to have the return address from the program counter, so that I can return back to the source of the jump command. That is like I would use a call function, but without altering the SP!
Are you out of stack space, or did someone give you some arbitrary "don't change the SP" directive ? You could recova a few bytes from the stack by popping into unused registers.
This sounds like a class project. So, here's a hint. Lookup the $ operator. Jon
I am not allowed to use a "call" function because I am not allowed to alter the stack pointer (SP). Huh, "not allowed"? Pray tell: who or what is stopping you? That restriction seems outright ridiculous. Does "making an omelett without breaking an egg" ring any bell to you?
"I don't wanna use a 'call' subroutine! I just use a 'jmp' command." Usa 'call' ta getta PC inta varaibil, den jumpta him!
So far, I have a first solution on my own:
mov r0, #high(return_label) mov r1, #low(return_label) ljmp sub_function return_label: ; any code here sub_function: clr a mov DPH, r0 mov DPL, r1 jmp @a+DPTR
Hi, Which language do you talk about? If ASM:
; somewhere in a program: MOV DPH,#HIGH(LABEL) MOV DPL,#LOW(LABEL) LABEL:
hi, I want to use a "jmp". ...so that I can return back to the source of the jump command. That is like I would use a call function, but without altering the SP! Sorry? Why not simple:
; main stream ; .... JMP MY_TASK ; go to your "subroutine" L_CONTINUE: ; contunue main stream MY_TASK: ; your piece of code JMP L_CONTINUE ; return to main stream
Yes, that should be Assembler :-) It is maybe a little bit different to the 8051 controller, but quite similar! Your example is somehow the same that I have!