.
Re: How to Add Local Variables to Your Functions
ugh, except it isnt - in your example anyway (actually counting the cycles is always a good idea).Which stack-clearing method the caller uses depends on how many params were pushed. You can probably see how this is the faster method.
stackframes arent exactly something "the big boys" invented either, its a common thing to do ever since.
Re: How to Add Local Variables to Your Functions
aha. so the one who writes those clearly wrong things isnt the clown here. point taken.
Re: How to Add Local Variables to Your Functions
the second method of adjusting the stack frame in your example is not faster as you said, it is 2 cycles slower.Feel free to jump in with facts
Re: How to Add Local Variables to Your Functions
Am I correct in thinking that 1 cycle = 1ns? Or is it 1ms?dudz wrote:the second method of adjusting the stack frame in your example is not faster as you said, it is 2 cycles slower.Feel free to jump in with facts
Is there any way to optimise it to recover those 2 cycles? Or would the code require a radical re-working?
Regards,
Shaun.
BASIC Programming - making the mistakes so that you don't have to.
Circles and Squares.
Nothing I post here will stand up in a court of law.
Circles and Squares.
Nothing I post here will stand up in a court of law.
-
- Member
- Posts: 55
- Joined: Wed Jun 11, 2014 2:33 pm
- Location: Lake Macquarie, NSW, Australia
- Contact:
Re: How to Add Local Variables to Your Functions
Shaun, one CPU cycle occurs for each CPU clock tick. It is independent of the speed of the CPU clock. A cycle at 20Mhz occurs twenty times the speed of a CPU cycle at 1Mhz. However, the clock speed is derived from the frequency of the domestic AC power used by the computer, which varies significantly between some regions of the world - most significantly between North America (60Hz) and Europe (50Hz). A stock or accelerated C64 in the USA will complete 1/5 more CPU cycles in a given amount of time than its counterpart C64 in Europe.
A 50Hz-region C64 at 1Mhz will process just under a million cycles per second.
For detailed information relevant to the C64, read this page:
http://unusedino.de/ec64/technical/misc ... -ntsc.html
As for recovering two cycles, your question is void because it seems both Dudz and Satpro were mistaken.
From a careful read of the discussion, it's apparent Dudz assumed Saptpro was referring to the Caller method's alternative for stack recovery. The first example used repeated "inx", while the alternative used "adc" and transferred data between X and A. He was quite correct that the alternative would take two cycles longer.
However, Satpro was referring to the "Caller Handles The Stack" method as being faster than the "Callee" method. But this statement was ambiguous because it immediately proceeded the stack recover alternative, hence Dudz' misinterpretation.
Had Satpro been curious enough to wonder what Dudz had seen in his article that invoked such a short and simple reply, then he would not have fired off his own misconceived response. It is quite apparent on closer inspection that Dudz' statement was justified, given the misinterpretation, and did not need further explanation - because a casual glance by any ML programmer would be enough to see that the alternative was indeed two cycles longer.
Fortunately, this is a discussion forum involving adults who enjoy programming. Criticism, even when misdirected, is useful and should be embraced, as it can often be used as an opportunity to explore new and better ways to do things.
A 50Hz-region C64 at 1Mhz will process just under a million cycles per second.
For detailed information relevant to the C64, read this page:
http://unusedino.de/ec64/technical/misc ... -ntsc.html
As for recovering two cycles, your question is void because it seems both Dudz and Satpro were mistaken.
From a careful read of the discussion, it's apparent Dudz assumed Saptpro was referring to the Caller method's alternative for stack recovery. The first example used repeated "inx", while the alternative used "adc" and transferred data between X and A. He was quite correct that the alternative would take two cycles longer.
However, Satpro was referring to the "Caller Handles The Stack" method as being faster than the "Callee" method. But this statement was ambiguous because it immediately proceeded the stack recover alternative, hence Dudz' misinterpretation.
Had Satpro been curious enough to wonder what Dudz had seen in his article that invoked such a short and simple reply, then he would not have fired off his own misconceived response. It is quite apparent on closer inspection that Dudz' statement was justified, given the misinterpretation, and did not need further explanation - because a casual glance by any ML programmer would be enough to see that the alternative was indeed two cycles longer.
Fortunately, this is a discussion forum involving adults who enjoy programming. Criticism, even when misdirected, is useful and should be embraced, as it can often be used as an opportunity to explore new and better ways to do things.
Re: How to Add Local Variables to Your Functions
in the above example there is simply a note missing that the second example is faster IF the stack needs adjustment by 5 or more bytes - in that case repeated INX are slower. for 4 bytes its the same, for 3 or less the INX stuff is faster. (and shorter!) if you make a macro for this, it could just choose between the two methods depending on the number of adjusted bytes.Is there any way to optimise it to recover those 2 cycles? Or would the code require a radical re-working?
Re: How to Add Local Variables to Your Functions
Okay, so why didn't you just say that in the first place?dudz wrote:in the above example there is simply a note missing that the second example is faster IF the stack needs adjustment by 5 or more bytes - in that case repeated INX are slower. for 4 bytes its the same, for 3 or less the INX stuff is faster. (and shorter!) if you make a macro for this, it could just choose between the two methods depending on the number of adjusted bytes.
Regards,
Shaun.
BASIC Programming - making the mistakes so that you don't have to.
Circles and Squares.
Nothing I post here will stand up in a court of law.
Circles and Squares.
Nothing I post here will stand up in a court of law.
Who is online
Users browsing this forum: No registered users and 5 guests