Shop OBEX P1 Docs P2 Docs Learn Events
Prop II Coding — Parallax Forums

Prop II Coding

hippyhippy Posts: 1,981
edited 2008-01-08 07:00 in Propeller 1
Assuming the Prop II has more than 64KB Ram, which is likely, all Propeller code which currently uses word variables to store pointers will likely break. This affects user code, particularly code in the Object Exchange with Spin and PASM code both affected.

It seems logical then that Propeller programmers should be using long variables for pointers for compatibility with Prop II but as this is wasteful on a Prop Mk I and word variables for pointers 'feel natural for a 64KB configuration' it's not happening - I'm as guilty as anyone else.

I can see two options; conditional compilation, so a programmer can use word variables for pointers on the Mk I and longs on a Mk II, or a new 'pointer' or 'addr' type which is 16-bit or 32-bit depending upon target compiled for. The later probably being the easiest to implement now as it can simply be an alias for "word" ( or "long" ) and any further complication caused to the Propeller Tool can be resolved in the fullness of time.

I think the issue needs some resolution now and people need educating and guiding in how they should code for both Mk I and Mk II compatibility. The longer the issue is ignored the more code which will break on the Mk II will exist. The last thing I think anyone wants is a flurry of "my code worked on Mk I but doesn't on the Mk II" posts to address, especially for Obex code and when it causes a lack of confidence in, or criticism of, the Mk II.

I would personally go as far as saying no code which is incompatible with the Mk II should be in the Obex when the Mk II is released and incompatible code there should be deleted.

One problem is that I am second-guessing how Spin etc will change for the Mk II, assuming byte[noparse][[/noparse] ], word[noparse][[/noparse] ] and long[noparse][[/noparse] ] will be valid for the full memory as it is now. If not that would add another level of difference. Although I appreciate the Mk II isn't necessarily fully defined and some way off, some guidance from Parallax would be appreciated.

Comments

  • Nick MuellerNick Mueller Posts: 815
    edited 2008-01-06 16:55
    > or a new 'pointer' or 'addr' type which is 16-bit or 32-bit depending upon target compiled for.

    Then you also need a rdpointer/rdaddr. wrpointer/wraddr

    Macros should work best and will solve some other bad coding-style too.


    Nick (did I once ask for "sizeof"? smile.gif)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO

    Post Edited (Nick Mueller) : 1/6/2008 6:42:59 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-06 17:12
    Hippy,
    Code that works on the current Propeller should work fine on the 256K as long as:

    1) You limit your program and data to the 1st 64K. Remember that the stack works upwards from the end of the program.

    2) All references to ROM are done using long values and these should be based on named constants. Many of the display drivers that use the built-in font tables "hard-code" the starting address of the font table.

    3) A few specific "got-ya"s in assembly language are accounted for that actually apply to the current Propeller. For example, the use of the C flag with WAITPxx instructions to indicate which "bank" of 32 I/O pins is referenced. This is defined for the current Propeller, but works OK if you ignore it. Some of the I/O drivers are written to handle this and some are not including some of mine.
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-06 17:13
    Maybe the first 64kB will look just like now (RAM+ROM)?
    Maybe after that will be a new area of 64 (or 128 KB) RAM?
    Maybe....
  • AleAle Posts: 2,363
    edited 2008-01-06 17:55
    Is not a bit early for that ?

    Memory is tight in the prop as it is, if they introduce conditional compiling all may be helped. Revising the code will be anyways necessary due to increased speed.
  • hippyhippy Posts: 1,981
    edited 2008-01-06 21:17
    @ Nick : Good point about rdpointer/rdaddr etc. ( I'd prefer 'addr' because in the VAR definitions it'll keep the variable names lined up nicely, all types four characters ). MoveAddr() and FillAddr() will also need adding.

    @ Mike : Keeping to under 64KB will work, but people will include objects where they end up above that 64K. Worse still, there will be code which by luck does work, but as development continues it stops working, that invariably leads people to thinking it's the code they'd just added which is faulty when the issue is far removed.

    Good points about the other changes which come with the Prop II, not just pointer size.

    @ deSilva : Rom could be kept where it is, but I think that would be a nightmare and a major kludge. Adjusting hard-coded addresses for Character , Sine and Cosine is going to be an issue as well. Unless that's done programmatically using ChipVer, conditional compilation is going to be a necessity for code which runs on both Mk I and Mk II.

    At some point I expect a Mk III will be considered, so it would be nice to have scalability resolved for the future rather than just hacking around Mk I to Mk II changes. If there's 128KB Rom as suggested, that also has to go somewhere, interleaved Ram and Rom is going to be horrible to deal with.

    @ Ale : It's never too early to start looking at potential problems. The 31st of December wouldn't have been a good time to start considering Millennium Bugs. It always annoys me when the Millennium Bug is cited as a 'failed prophecy' because it never materialised as feared; only because so much effort went into ensuring it didn't !

    IMO, far better to start worrying now and have a smooth transition later than put it to one side and have 'blind panic' when Prop II arrives and issues haven't been resolved or even looked into.

    I agree that memory is often tight on a Prop Mk I, and that will lead to a reluctance to use longs for pointers ( I feel that way ). Thus the Propeller Tool has to provide the mechanisms to make both Mk I and Mk II use optimal for each.
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-06 23:15
    hippy said...
    @ deSilva : Rom could be kept where it is, but I think that would be a nightmare and a major kludge. Adjusting hard-coded addresses for Character , Sine and Cosine is going to be an issue as well. Unless that's done programmatically using ChipVer, conditional compilation is going to be a necessity for code which runs on both Mk I and Mk II.

    I have no idea what issues you are talking about... Leaving the ROM where it is, is the only possible compatible solution. Many old SPIN programs will run!

    Utilizing the Prop II features would need starting your programs @ 64k. The low 32 kb can be used for stack data, video memory... It is not such an issue that it is not consecutive.

    Post Edited (deSilva) : 1/7/2008 7:55:59 PM GMT
  • hippyhippy Posts: 1,981
    edited 2008-01-07 00:59
    True, keeping the bottom 64K as it is now will be okay for existing Prop Mk I programs, providing they do not grow in size when the Prop II becomes available. The low 32K could be used for stack and video but that's quite a waste for people using lightweight text-only video and don't need a large stack. As soon as anything stretches across the Rom 'gap' it becomes a problem, a complication.

    There are three issues really; running Prop I programs on a Prop II, writing objects which will run on either Prop I or Prop II, expanding Prop I programs once they move to a Prop II.
  • Nick MuellerNick Mueller Posts: 815
    edited 2008-01-07 07:19
    > There are three issues really; running Prop I programs on a Prop II, writing objects which will run on either Prop I or Prop II,
    > expanding Prop I programs once they move to a Prop II.

    A ROM-relocation-register. If not set (non Prop II aware programs), the original ROM moves to where it was in the Prop I.
    But I certainly woudndn't like the ROM to lie in the middle of RAM.

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-01-07 08:29
    If·compatibility for existing programs is really important to Parallax,
    they should follow the Intel x86 method, eg. address segmentation.
    That means the prop II could run multiple prop I programs (if cogs available)
    because each program runs in its own segment (like .COM programs).
    A virtual mode register can put the prop II·in virtual mode, allowing programs
    to use more than 32KByte ram. This could be activated by the downloader
    if a special tag (like used for the basic stamps) is used, or instructed
    by the program itself by setting the virtual mode register.

    regards peter
  • Nick MuellerNick Mueller Posts: 815
    edited 2008-01-07 09:49
    > If compatibility for existing programs is really important to Parallax, they should follow the Intel x86 method

    Whenever I hear "Intel" and "x86", I get curly footnails! smile.gif
    Please no pages, segments, A20 or other oddities.

    Having had a look at the registers and RAM-map, I see that there is no room left for an extra configuration-register (without losing valuable COG-RAM). But at least the downloader in ROM could reject files that are for the Prop I (some signature or lack thereof or such).
    I personally could live well with that. I really prefer making things simple and straight. As soon as compatibility-Smile is introduced, new problems pop up in every corner.

    KISS!

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • CardboardGuruCardboardGuru Posts: 443
    edited 2008-01-07 10:06
    Peter Verkaik said...
    If compatibility for existing programs is really important to Parallax,
    they should follow the Intel x86 method, eg. address segmentation.

    NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!!!!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Help to build the Propeller wiki - propeller.wikispaces.com
    Play Defender - Propeller version of the classic game
    Prop Room Robotics - my web store for Roomba spare parts in the UK
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-01-07 10:42
    I agree with CardboardGuru. Keep the propeller memory map as simple as possible. Any code that is timing critical will probably have to change anyway, so there is going to be a lot of code that is broken. Any spin code that doesn't access the rom should probably be alright though. If you really want to do something, have some kind of flag in the compiled program (maybe per object?) that indicates that the program uses propI addressing for eeprom. Then it would be a simple matter for the interpreter to fix up the addresses. I think ultimately we are going to have to accept that anything that accesses the rom or is timing critical is probably going to be broken.

    However, it should be a simple fix. Just the appropriate offset to everything that accesses the rom. If we had macros and a preprocessor then you could even make an object that could run on either.
  • simonlsimonl Posts: 866
    edited 2008-01-07 10:51
    IMHO: It's not like Parallax for complicate anything - they know their customer-base very well! I fully expect that PropII will have a contiguous RAM map (I think they've already mentioned that they dislike memory paging.).

    Further, I expect that code written for PropII will _have_ to have some sort of PropVer setting in order for the Propeller Tool to compile above 32K anyway - isn't that what they did with the Stamp?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,

    Simon
    www.norfolkhelicopterclub.co.uk
    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
    BTW: I type as I'm thinking, so please don't take any offense at my writing style smile.gif
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-01-07 10:58
    Don't know about the Stamp. But the propeller does have a way of reading the version number of the chip so you could actually read which version the chip was and then adjust a pointer to the rom at runtime. Thats not hard. So we may be actually making a big deal out of nothing.

    Steven
  • CardboardGuruCardboardGuru Posts: 443
    edited 2008-01-07 11:14
    The Propeller market is as yet tiny. There's no market at all for Propeller software. Software comes into these categories:

    1) The developer hasn't distributed it. He has the source and can alter it if he moved to Prop 2.
    2) The developer distributes software to customers as part of hardware product that includes a Propeller. The only way that the user will be moving to the Prop 2 is if they buy a different hardware product. And that will come with Prop2 software included.
    3) The developer has open sourced the software and distributed it via the forums or obex. Everyone has the source, the original developer can update it for Prop2 or anyone else can.

    It appears that the current spin compiler assumes a 64K memory map. So binaries for Prop 2 will be different from binaries for Prop 1. But that's not an issue as software is rarely distributed as binaries.

    I don't believe it would be worth any architectural tricks or compromises at all to make the Prop 2 100% compatible with Prop 1 binaries. Just update Spin to use 32 bit addresses internally, and put the ROM at the top of the 32 bit address space.

    Source code needs some small changes, as already outlined for LONG pointers, ROM accesses and the odd case where flags do something on the Prop2 that they don't on the Prop 1. It's no big deal. We're already used to having to modify source to get software working on different development boards.

    But Parallax can do one thing to really help the transition, and make inter board portability easier too. Add conditional compilation to Prop Tool. The sooner the better.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Help to build the Propeller wiki - propeller.wikispaces.com
    Play Defender - Propeller version of the classic game
    Prop Room Robotics - my web store for Roomba spare parts in the UK
  • hippyhippy Posts: 1,981
    edited 2008-01-07 11:38
    I support the KISS ideology, a contiguous linear Ram section followed by Rom, an existing model which serves the Mk I well and would the Mk II. Making the Mk II be Mk I compatible isn't IMO necessary; most programmers are used to portable coding for different architectures, the important things are the tools to allow coding for the different architectures so single source files can be delivered which work with both.
  • javerjaver Posts: 6
    edited 2008-01-07 12:22
    I just want to ask a simple question: Why byte must have 8 bits? On example, if Prop 2 uses the same organization as Prop 1, but with bytes of 10 bits, WORD will have 20 bits (for addressing up to 1MB), and long will have 40 bits. At the source level, everything (almost) will be compatible. And, it is very scalable. Assembler commands will be expanded from 32 to 40 bits - I suppose extra 8 bits is enough for all addressing modes. There can be some additional commands for mapping 8-bit bytes to one of 5 possible position in 40-bit words, used for boot loading and for hardware access (only external hardware may need 8 bit organization).
    For Prop 3 (far in future), byte can have 12 bits, and so on.

    yawer
  • CardboardGuruCardboardGuru Posts: 443
    edited 2008-01-07 12:36
    Hi Javer,

    You'd be opening a can of worms if a byte wasn't 8 bits. 8 bit bytes are just so ingrained in so many things.

    But your objective isn't necessary. There is nothing about the current 32 bit instruction format that limits it to a 16 bit address space. The format is completely compatible with a 32 bit address-space without change. The instructions only ever hold Cog RAM addresses, not Hub RAM addresses. Hub RAM Addresses are held in registers and registers are 32 bit already.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Help to build the Propeller wiki - propeller.wikispaces.com
    Play Defender - Propeller version of the classic game
    Prop Room Robotics - my web store for Roomba spare parts in the UK
  • Nick MuellerNick Mueller Posts: 815
    edited 2008-01-07 13:49
    > if Prop 2 uses the same organization as Prop 1, but with bytes of 10 bits, WORD will have 20 bits (for addressing up to 1MB),
    > and long will have 40 bits.

    In that case, I prefer waiting for the Prop III which is a 64 bit Processor having 128 COGs, 2MB of COG RAM and 4GB HUB-RAM. I can see it clearly in my crystall ball!


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • rjo_rjo_ Posts: 1,825
    edited 2008-01-07 14:48
    Javer,

    You are correct.

    It took many years for a byte to go from 7 bits to 8 and now you want 10?

    Your idea is a bit inflationary[noparse]:)[/noparse]

    Better to go to ternary logic... the hardware is already in the Prop... sort of[noparse]:)[/noparse] Ternary logic would give you 12+ bits per byte and no hardware changes.

    Rich
  • SapiehaSapieha Posts: 2,964
    edited 2008-01-07 15:27
    Hi All

    My solution on ROM problem ..

    With start Prop I program one extra instruction to copy ROM to Prop I addres in Prop II continguos Ram

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.

    Sapieha
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-01-08 07:00
    I like that Sapieha. The compiler could even do it automatically. Simply have an option (or something like _propVersion in one of the CON sections) and the compiler will automatically add in a bit of code at the start of the program to move the ROM into the RAM. It doesn't get around timing issues but it is an excellent idea.

    Steven
Sign In or Register to comment.