Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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

List of 53 messages in thread
TopicAuthorDate
Week puzzle            01/01/70 00:00      
   why is one a subroutine and another a ta            01/01/70 00:00      
      no RTOS            01/01/70 00:00      
   last there was discussion, in this an an            01/01/70 00:00      
      week            01/01/70 00:00      
   Last pushed in - first popped out            01/01/70 00:00      
      come in            01/01/70 00:00      
   Will it work?            01/01/70 00:00      
      Yes it will            01/01/70 00:00      
         Mmmmm?            01/01/70 00:00      
         And another thought            01/01/70 00:00      
            it's perfectly safe...            01/01/70 00:00      
               Still not convinced            01/01/70 00:00      
                  dangers            01/01/70 00:00      
                     Choices            01/01/70 00:00      
                        the same in real life            01/01/70 00:00      
                           Smart and Neat Code            01/01/70 00:00      
                              are you a math major? :)            01/01/70 00:00      
                                 Not a maths major            01/01/70 00:00      
                        yes            01/01/70 00:00      
                  what dangerous            01/01/70 00:00      
                     If misuse is chronic...            01/01/70 00:00      
   CALL + RET != JUMP            01/01/70 00:00      
      ?????????            01/01/70 00:00      
         oops Oleg Has the code to manage it sorr            01/01/70 00:00      
            return address            01/01/70 00:00      
      you got it!            01/01/70 00:00      
         Thanks for the puzzle :-)            01/01/70 00:00      
   a question            01/01/70 00:00      
      why not            01/01/70 00:00      
         well            01/01/70 00:00      
            optimisation            01/01/70 00:00      
               I have seen that happen when the require            01/01/70 00:00      
                  it's the same than if you miss a push or            01/01/70 00:00      
         The Trick is:            01/01/70 00:00      
   the answer            01/01/70 00:00      
      you never answered            01/01/70 00:00      
         solid or intermittent problem            01/01/70 00:00      
            difference between solid or intermittent            01/01/70 00:00      
   Why Push!!!            01/01/70 00:00      
      side effect            01/01/70 00:00      
         Another SAVE_CONTEXT            01/01/70 00:00      
            Sounds like a housekeeping nightmare            01/01/70 00:00      
               Sounds like a housekeeping nightmare            01/01/70 00:00      
               it IS a housekeeping nightmare            01/01/70 00:00      
                  Erik            01/01/70 00:00      
                     Pay no attention            01/01/70 00:00      
                        Donald, if you took the time to read wha            01/01/70 00:00      
                           Reading difficulties            01/01/70 00:00      
                              sorry, used wrong word            01/01/70 00:00      
                     no problem with any post, just with stat            01/01/70 00:00      
            maybe because            01/01/70 00:00      
      eh?            01/01/70 00:00      

Back to Subject List