Shop OBEX P1 Docs P2 Docs Learn Events
Compiler question — Parallax Forums

Compiler question

lardomlardom Posts: 1,659
edited 2012-09-04 05:59 in Propeller 1
Where is the compiler located in the Propeller block diagram? I'm thinking that the compiler and the processor perform different functions and have different physical locations. (There is still a ton of stuff for me to learn and at the moment I'm trying to get a better grasp of Prop architecture.)
BTW it just occurred to me that cogs had to have processors located outside cog ram. Maybe the processor compiles code during the boot phase and then executes code during runtime.
While studying some simple PASM I thought that learning how the Prop handles code would answer a bunch of my questions.

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-09-02 22:29
    Hi Larry,
    Oh boy, are you coming in from the wrong end :) A compiler is software that normally runs on a host such as a PC that takes source code and compiles it into the machine code of the target processor. The target processor is the Propeller which is in fact 8 processors or cogs in Propeller lingo. The cogs like all other processors only know how to execute their machine code instructions, that's it, all the rest is smoke and mirrors. The cog RAM is an integral part of the cog, it is the hub RAM that is outside but common to all 8 cogs
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-09-02 22:32
    The compiler does not exist in the Propeller at all, but in your PC. The compiler takes the Spin/PASM source code and converts the Spin to "bytecodes" and the PASM to machine code. These are what get loaded into the Prop's hub RAM during an upload. In the case of Spin, a bytecode interpreter is launched into a cog from hub ROM. The interpreter is a PASM program which reads bytecodes from hub RAM and executes them. In doing so, it emulates a virtual machine that has its own instruction set, i.e. the bytecodes that the Spin compiler produced.

    -Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-03 06:46
    The compiler is a program that usually runs on your PC, but can also run on the Propeller. There's an "operating system" for the Propeller called Sphinx that includes some I/O drivers and a bunch of utility programs stored on an SD card attached to the Propeller. One of these programs is a Spin compiler / PASM assembler that reads a program from an SD card file and produces a partially compiled program. There's also a "linker" program that reads one or more of these partially compiled programs from the SD card and combines them into a regular Spin / PASM binary file that can be loaded and run like those produced by the Propeller Tool. Because of the Propeller's limited memory, the Sphinx compiler is missing a few Spin features like the ability to process floating point constant expressions and it has smaller limits on the number of methods in an object, etc.
  • lardomlardom Posts: 1,659
    edited 2012-09-03 08:19
    @Peter, Phil and Mike, thanks for clearing that up.
    (You are among those I owe a humongous thanks to whenever I look at the stuff I've created.)
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-09-03 13:34
    Hmmmmm all the answers given are completely 100% correct and I hope they have cleared up your confusion. But im wondering if maybe you were talking about something else and everyone kind of missed the ball on this one.

    When I read your post it seems as though you were reading through the prop manuals architecture section and got a little confused. The propeller has no compiler on it as stated above but it does have a Spin Interpreter built in, this would be analogous to python or QBasic on a PC. The propeller chip is made of 8 cores (or cogs in propeller speak) each core has 2k of ram attached to it which can only be accessed by that core. The propeller also has what is called the Hun which has 32k of ram, Hub ram can be accessed by all 8 cores but they have to take there turn reading and writing to it, the hub starts at the first core and lets it access hub ram then moves around to each core in numerical order doing the same, in a circular "round robin fashion". Te propeller has ROM built into it which holds the spin interpreter, when the chip is booted it loads the interpreter into cog0, then it fetches spin code it first looks at the the TX/RX serial pins to check for a pc connection if it doesnt find one it then moves on and loads code from the eeprom. The eeprom is basically just ROM where you save the spin/pasm/gcc code for your propeller to use when disconnected from the pc.

    As I said im not sure if this is what you were talking about, but when I read your post it really made me think your were asking where the spin interpreter lives and how it executes code. If im way off from the original question I apologize but maybe this still helped you learn a little bit more about whats going on.
  • lardomlardom Posts: 1,659
    edited 2012-09-03 21:42
    @rwgast_logicdesign, I've reached the sophmore level with Spin but I'm a novice in my understanding of how a microcontroller works. While trying to understand PASM I read that the cog loaded 496 longs and I couldn't figure out how anything could be done since the cog 'ran out of room'! I was really stuck.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-09-03 21:57
    lardom wrote: »
    @rwgast_logicdesign, I've reached the sophmore level with Spin but I'm a novice in my understanding of how a microcontroller works. While trying to understand PASM I read that the cog loaded 496 longs and I couldn't figure out how anything could be done since the cog 'ran out of room'! I was really stuck.
    While 492 longs is a bit of a limit the cog's "instruction set" makes up for it a bit with it's flexibility. Phil mentioned bytecode earlier and basically the bytecodes which are compiled into the 32K of hub RAM are an "instruction set" for a virtual machine processor created by loading one of the cogs with just enough code to get it to pretend the 32K of RAM and 32K of ROM is it's code space and the bytecodes are it's instructions. That's what Spin is as opposed to PASM. It's slower but at a higher level too. My Tachyon Forth which is a complete system, compiler, debugger, is implemented in this way. Yes, 492 longs can go a "long" way :)
  • lardomlardom Posts: 1,659
    edited 2012-09-04 05:59
    @Peter Jakacki, Thanks. I see you're a YouTuber. I subscribed.
Sign In or Register to comment.