View Single Post
Old 25 August 2015, 18:21   #330
Registered User

Dunny's Avatar
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 993
Originally Posted by Mrs Beanbag View Post
Procedure calls are apparently very costly, don't ask me why
It's because the parameters have to be placed somewhere before the procedure is called. Commonly, your compiler/interpreter will set up a stack in memory which has enough space for the values you're passing, then write them in (at runtime, regardless of whether or not you're using a compiler or interpreter) and then issue a call to the procedure, which has been compiled to pull its parameters from the stack. Even parameters passed by reference have their pointer values stacked and then re-read out during the procedure.

Modern compilers will of course store parameters in registers where available before touching the stack, but I'm not sure how often that sort of thing was done back in the day - it's quite an old method.

There are also other methods available now with these days of large CPU caches to mitigate this speed penalty, but for things like AMOS they couldn't be taken advantage of.

Dunny is offline  
Page generated in 0.03977 seconds with 10 queries