??? 08/12/05 13:49 Read: times |
#99275 - side effect Responding to: ???'s previous message |
hi,
Mehdi said:
For every push instruction you occupy one ram location,
So It seems you can easily save your required registers in to ram locations without any pushing! If I understand right so your idea is to allocate RAM space and save registers there then restore them from there, like next: ?DT?HOLDER SEGMENT DATA RSEG ?DT?HOLDER HOLDER: DS 11 ; ; A_SUBROUTINE: CALL SAVE_CONTEXT ; a task CALL RESTORE_CONTEXT RET ; ; SAVE_CONTEXT: MOV HOLDER,R0 MOV HOLDER+1,R1 MOV HOLDER+2,R2 MOV HOLDER+3,R3 MOV HOLDER+4,R4 MOV HOLDER+5,R5 MOV HOLDER+6,R6 MOV HOLDER+7,R7 MOV HOLDER+8,A MOV HOLDER+9,DPH MOV HOLDER+10,DPL RET RESTORE_CONTEXT: MOV R0,HOLDER MOV R1,HOLDER+1 MOV R2,HOLDER+2 MOV R3,HOLDER+3 MOV R4,HOLDER+4 MOV R5,HOLDER+5 MOV R6,HOLDER+6 MOV R7,HOLDER+7 MOV A,HOLDER+8 MOV DPH,HOLDER+9 MOV DPL,HOLDER+10 RET Well, now imagine what happenes if you try next:: A_SUBROUTINE1: CALL SAVE_CONTEXT ; some doing CALL A_SUBROUTINE2 ; some doing CALL RESTORE_CONTEXT RET ; A_SUBROUTINE2: CALL SAVE_CONTEXT ; some doing CALL RESTORE_CONTEXT RET I think you catch the limitation of your method, do you? Regards, Oleg |