SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Technology Stocks : Advanced Micro Devices - Moderated (AMD) -- Ignore unavailable to you. Want to Upgrade?


To: Joe NYC who wrote (74148)3/10/2002 3:14:45 AM
From: bacchus_iiRead Replies (1) | Respond to of 275872
 
Joe,


Can this be done (using registers instead of pushing parameters on the stack)? I have my doubts about it. Isn't the result just the opposite, that is when a function is called, doesn't more registers need to be stored?


I have seen, long ago, computer implementing in hardware a sort of cache holding the top n words of the stack. I never saw this for the X86. It's mostly interesting when polish string notation is used to execute operation with operand from the stack and result (including intermediate result) stored also on the stack.


My assembly skills are extremely rusty, (as you can probably tell from the question), maybe you can refresh my memory. What happens when a function is called? Can you assume that the state of the registers is the same as prior to the call? If the answer is yes, they need to be stored someplace (on stack), so 8 extra registers presents extra overhead? Is there a shortcut for finding out which registers need to be saved?

It could be a software programming discipline I guess. The saving should than be done by the subroutine at the entry and the saving should then be done only for the register that will be needed by the subroutine.
Of course for context change, all registry got to be saved and restored for the new tread context. Maybe for interrupt service routine, for very small ISR, a reduced set of register could be saved, provide this small ISR return only to the interrupted tread.

Note: all this is WAG from me since my assembler is more far away then yours.

Gottfried



To: Joe NYC who wrote (74148)3/10/2002 5:54:36 AM
From: pgerassiRead Replies (1) | Respond to of 275872
 
Dear Jozef:

This is usually decided in the calling conventions of the given compilers. If you are using assembly throughout, you can decide on the conventions used within your code. For OS context switches, the full state is restored to work within the OS, so all registers are considered altered except of course for EIP. For OS system calls, what is saved depends on what is requested to be done and where the results go (decided by the OS conventions). For device drivers, they need to restore everything to exactly what it was before doing anything when they return. They also must be fully reentrant as another task may interrupt them, even another call to the exact same routine being interrupted. However If the device driver only alters 5 registers, they only need to save and restore those 5.

Most RISC machines must save dozens of registers and they are still faster than machines using only a few (like the old 6502). But, that is the point, you decide how those registers are used, saved and restored. You are not forced to use memory (stack) for it all.

Pete