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

Stack

Hello,
I'm working on the XC164X µc and I've a question concerning the storage of registers in stack when interrupt occur.

The function is written in c language

void ItFunc (void) interrupt 14
{ funcCode ();
}

The pre-processor code is as follow:

ItFunc PROC INTERRUPT = 14 GLOBAL ItFunc
; FUNCTION ItFunc (BEGIN RMASK = @0x3FFF)

SCXT DPP3,#3

PUSH DPP0

SCXT MDC,#16

PUSH MDH

PUSH MDL

MOV [-R0],R1

MOV [-R0],R2

MOV [-R0],R3

MOV [-R0],R4

MOV [-R0],R5

MOV [-R0],R6

MOV [-R0],R7

MOV [-R0],R8

MOV [-R0],R9

MOV [-R0],R10

MOV [-R0],R11

MOV [-R0],R12

; line 234: funcCode ();

CALL funcCode

?C0005:

MOV R12,[R0+]

MOV R11,[R0+]

MOV R10,[R0+]

MOV R9,[R0+]

MOV R8,[R0+]

MOV R7,[R0+]

MOV R6,[R0+]

MOV R5,[R0+]

MOV R4,[R0+]

MOV R3,[R0+]

MOV R2,[R0+]

MOV R1,[R0+]

POP MDL

POP MDH

POP MDC

POP DPP0

POP DPP3

RETI

; FUNCTION ItFunc (END RMASK = @0x3FFF)

ItFunc ENDP

?PR?BS_TST ENDS

As shown in this pre-processor code, we use the register R0 to save the registers R1—R12.
I'd like to store the registers using the instruction PUSH R1.
How can I do this? Which directive could I use that the compiler store the registers in stack using the instruction "PUSH R1" and not using "MOV [-R0], R1"

Thanks

Parents
  • No, the compiler really do decide what to do. We write source code to inform it what we want solved, and we use directives to give it hints about how to solve it.

    If it was you who decided what to do, then you wouldn't need to buy the compiler, since you would not have any need for it. The way you decide what to do, is by writing the program in assembler.

Reply
  • No, the compiler really do decide what to do. We write source code to inform it what we want solved, and we use directives to give it hints about how to solve it.

    If it was you who decided what to do, then you wouldn't need to buy the compiler, since you would not have any need for it. The way you decide what to do, is by writing the program in assembler.

Children
No data