spin interpreter: how does it interpret the byte code
Chris Micro
Posts: 160
Hallo together,
as the spin interpreter source code is open, I try to understand how it works.
I traced with my emulator through the code.
In the interpreter source we can find the folowing:
' par word
'
' +2 pbase
' +4 vbase
' +6 dbase
' +8 pcurr
' +A dcurr
pcurr seems to mean "current programm counter" which points to the current byte to be interpreted.
What is the meaning of the other labels?
thanks for joining the discussion,
chris
as the spin interpreter source code is open, I try to understand how it works.
I traced with my emulator through the code.
In the interpreter source we can find the folowing:
' par word
'
' +2 pbase
' +4 vbase
' +6 dbase
' +8 pcurr
' +A dcurr
pcurr seems to mean "current programm counter" which points to the current byte to be interpreted.
What is the meaning of the other labels?
thanks for joining the discussion,
chris
Comments
pbase = hub address of start of object
vbase = hub address of start of global variables
dbase = hub address of start of stack
pcurr = program counter
dcurr = stack pointer
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Release the hounds!
Post Edited (BradC) : 7/13/2009 10:20:04 AM GMT
I created a more or less senseless program:
With your incredible useful BSTC I got the following listing:
From this I can get some very useful information, but some things I do not really understand about the spin interpreter:
Addr : 0023: 01 : Drop Anchor ==> what does Drop Anchor do?
Addr : 0025: 05 02 : Call Sub 2 ==>
does Call Sub 2 mean that the interpreter calls the routine from the current program counter +2 or is there a label list somewhere in the code which used as jump address?
Drop Anchor is a phrase I got from the interpreter source. It pretty much means prepare the stack for a function call.
Call Sub 2 : means, call subroutine method 2 in the current method table.
The header for each spin method lists the method numbers. The interpreter gets this information from the method table at the start of each object.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Release the hounds!
Probably it would be possible with the insights of this thread to write a spin object analyzer.
Homespun also provides a listing in a different format, so you might also get some other infor from this.
Also look at my thread for the faster spin interpreter (see "tools" link in my signature below for this). There is a description of the interpreter instructions there.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBladeProp, RamBlade, TwinBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index) ZiCog (Z80), MoCog (6809)
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm