Shop OBEX P1 Docs P2 Docs Learn Events
OSX/Win32/Linux Spin Compiler-0.15.3 - Page 2 — Parallax Forums

OSX/Win32/Linux Spin Compiler-0.15.3

2456

Comments

  • BradCBradC Posts: 2,601
    edited 2008-10-01 08:19
    stevenmess2004 said...
    Looks cool,

    I get the following when I try to compile RGW_JTC_TinyBasic_010.spin from the hydra cd

    steven-messengers-computer:~ stevenmessenger$ /Users/stevenmessenger/Downloads/bstc.osx -l /Users/stevenmessenger/Documents/Projects/Propeller/Hydra/demos/JT_Cook/T_Basic_Mod_08_06_07/RGW_JTC_TinyBasic_010.spin 
    Brads SpinTool Compiler v0.02 - Copyright 2008, All rights reserved
    Compiled for i386 Darwin at 12:04:01 on 2008/09/30
    Loading Object RGW_JTC_TinyBasic_010
    Loading Object RGW_JTC_HTBasic_Support_010.spin
    Loading Object RGW_keyboard_iso_010.spin
    Loading Object RGW_HTBasic_Constants_010.spin
    Loading Object JTC_char_display_001.spin
    Loading Object rem_tv_014.spin
    Loading Object JTC_char_engine_001.spin
    Loading Object RGW_HTBasic_Constants_010.spin
    Math Stack Underflow!
    Math Stack Underflow!
    
    


    And then it doesn't do anything and doesn't return to the command line.

    Looks like a parse error in RGW_HTBasic_Constants_010.spin. Any chance of a copy of the source?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • BradCBradC Posts: 2,601
    edited 2008-10-01 12:28
    New version 0.03 (See top post)

    New spin instruction for those getting into the guts of things
    BYTECODE()
    It lets you insert raw spin bytecodes directly into the method. Can be used pretty much anywhere... see below for an example
    |===========================================================================|
    Spin Block ABCDE with 0 Parameters and 2 Extra Stack Longs. Method 1
    PUB ABCDE | X2, X3
    |===========================================================================|
    13                              X2 := 1
    Addr : 0038:             36  : Constant 2 $00000001
    Addr : 0039:             65  : Variable Operation Local Offset - 1 Write
    14                              bytecode($36, $65)
    Addr : 003A:             36  : Constant 2 $00000001
    Addr : 003B:             65  : Variable Operation Local Offset - 1 Write
    15                              X3 := 3 + bytecode($36) / 5
    Addr : 003C:          37 21  : Constant Mask Y=33 Decrement 00000003
    Addr : 003E:             36  : Constant 2 $00000001
    Addr : 003F:          38 05  : Constant 1 Bytes - 05 
    Addr : 0041:             F6  : Math Op /     
    Addr : 0042:             EC  : Math Op +     
    Addr : 0043:             69  : Variable Operation Local Offset - 2 Write
    Addr : 0044:             32  : Return        
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • Cluso99Cluso99 Posts: 18,069
    edited 2008-10-02 02:13
    Just what I need to brute test my Interpreter - Thanks heaps smile.gifsmile.gif

    Post Edited (Cluso99) : 10/12/2008 12:41:18 PM GMT
  • rjo_rjo_ Posts: 1,825
    edited 2008-10-13 03:17
    Hi Brad,

    You are correct. bstc is exactly what I would want.

    Finally found this thread thanks to Cluso99's thread...

    When you suggested bstc... I thought you were talking about c language sources:O)

    bstc finds my prop and runs as advertised.

    I cannot get option 2 to work under OS X 10.4.1.1 on a G5...? I assume that I can just compile and then load it using the loader.

    Thanks again


    Rich
  • BradCBradC Posts: 2,601
    edited 2008-10-13 03:28
    rjo_ said...
    Hi Brad,

    You are correct. bstc is exactly what I would want.

    Finally found this thread thanks to Cluso99's thread...

    When you suggested bstc... I thought you were talking about c language sources:O)

    bstc finds my prop and runs as advertised.

    I cannot get option 2 to work under OS X 10.4.1.1 on a G5...? I assume that I can just compile and then load it using the loader.

    Option 2? As in Load EEProm and Run ?
    If not then I'll get it fixed. If bst works for you and bstc does not then I've done something silly as they both share the same compiler/loader code.
    Does -p0 or -p1 work for you ?

    Brad

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • rjo_rjo_ Posts: 1,825
    edited 2008-10-13 12:59
    that would be silly[noparse]:)[/noparse] I looked right at it and couldn't figure out why there was no -.

    works fine.

    for any other idiots out there... there is a line in the instructions that looks like this:

    -p[noparse][[/noparse]012] - Program Chip on device (-d),
    which seems to say use -p012 -d to Program chip on a particular device d...

    that's not what it says... it says (for example) use -p2 to compile and load EEProm[noparse]:)[/noparse]

    So, your final command line instruction should look something like this

    /Parallax/bstc.osx -p2 /Parallax/simpleterminal.spin

    Post Edited (rjo_) : 10/13/2008 1:09:07 PM GMT
  • BradCBradC Posts: 2,601
    edited 2008-10-21 04:12
    Version 0.06 released - See top post.

    What happened to 0.04 & 0.05? They were internal fixes and releases incorporated into bst.
    Major changes?
    - Assembly listing
    - Improved Propeller detection / download
    - Bugfixes

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • BradCBradC Posts: 2,601
    edited 2008-10-21 05:53
    Fixed downloading

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!

    Post Edited (BradC) : 10/21/2008 8:50:53 AM GMT
  • SapiehaSapieha Posts: 2,964
    edited 2008-10-21 16:40
    Hi BradC.

    Have loaded and tested BSTC 07 and have problem to compile.

    ERROR.

    H:\Arbets\_Div Spin Code\-_ HardWare\HardWare\Homespun Spin compiler\BSTC>bstc -
    l -o FullDuplexSerial4in1.spin FullDuplexSerial4in1.spin
    Brads SpinTool Compiler v0.07 - Copyright 2008, All rights reserved
    Compiled for i386 Win32 at 13:20:24 on 2008/10/21
    Loading Object FullDuplexSerial4in1
    An unhandled exception occurred at $0041F40B :
    EStringListError : List index (277) out of bounds
    $0041F40B

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer.
    Don't guess - ask instead.
    If you don't ask you won't know.
    If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


    Sapieha
  • BradCBradC Posts: 2,601
    edited 2008-10-21 17:33
    Sapieha said...
    Hi BradC.

    Have loaded and tested BSTC 07 and have problem to compile.

    ERROR.

    H:\Arbets\_Div Spin Code\-_ HardWare\HardWare\Homespun Spin compiler\BSTC>bstc -
    l -o FullDuplexSerial4in1.spin FullDuplexSerial4in1.spin
    Brads SpinTool Compiler v0.07 - Copyright 2008, All rights reserved
    Compiled for i386 Win32 at 13:20:24 on 2008/10/21
    Loading Object FullDuplexSerial4in1
    An unhandled exception occurred at $0041F40B :
    EStringListError : List index (277) out of bounds
    $0041F40B

    Can you send me a copy of that spin file please?
    I *think* I know where the problem is, but I need to reproduce it precisely to check.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • SapiehaSapieha Posts: 2,964
    edited 2008-10-21 19:44
    Hi BradC.

    It is file that produced this error.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer.
    Don't guess - ask instead.
    If you don't ask you won't know.
    If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


    Sapieha
  • JasonDorieJasonDorie Posts: 1,930
    edited 2008-10-21 20:38
    I'm curious about the level of optimization done by the current compiler. I have lots of code where objects have methods to retrieve internal variables, like this:

    PUB GetX
    return xValue


    And those objects are used like this:


    OBJ
    SO : "SomeObject.spin"

    PUB Function | x, y
    x := SO.GetX


    Does the current SPIN compiler (or this one by BradC) do anything to optimize this case? Does the compiler actually call the 'GetX' method to get the variable? Given the global knowledge the compiler has, this could become a direct memory location access. Does the compiler make any attempt at 'inlining' like this?

    If the compiler doesn't optimize this case, is it possible to directly access VAR members of an object instead of using access functions?

    Thanks,
    Jason
  • evanhevanh Posts: 16,152
    edited 2008-10-21 20:59
    Umm, It's wrong to call bst a compiler. There is no reconstructing of the program taking place.

    Tokeniser is prolly the best name.
  • BradCBradC Posts: 2,601
    edited 2008-10-22 04:10
    JasonDorie said...
    I'm curious about the level of optimization done by the current compiler. I have lots of code where objects have methods to retrieve internal variables, like this:

    PUB GetX
    return xValue


    And those objects are used like this:


    OBJ
    SO : "SomeObject.spin"

    PUB Function | x, y
    x := SO.GetX


    Does the current SPIN compiler (or this one by BradC) do anything to optimize this case? Does the compiler actually call the 'GetX' method to get the variable? Given the global knowledge the compiler has, this could become a direct memory location access. Does the compiler make any attempt at 'inlining' like this?

    If the compiler doesn't optimize this case, is it possible to directly access VAR members of an object instead of using access functions?

    Thanks,
    Jason

    The answer to both of those is no. Here is why.
    As objects can be assigned to arrays, there is no certain way of knowing which objects variable segment you are going to access when you do an object call.
    It *possibly* could be done for your case where the object is a single, but then the compiler has no real understanding of the contents of the GetX call. It could be far more than just a "return X" and therefore would not be possible to optimise away.

    Additionally, until the final object distill and link is done, each object is a completely stand alone bit of memory, so the compiler does not know where the variables for other objects are being placed until the very last moment. You can access the var members of an object quite easily however by passing a reference to the variables address using the @ operator.

    The only "optimisation" bst/bstc does at the moment is unused method removal, constant folding and some minor size/speed optimisations to do with addresses and constants. I've not pushed it any further at this time, although dead code removal and branch optimisation are things I'm thinking about (In addition to some tricks to compact the data segment used by STRING() at the end of the object).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • BradCBradC Posts: 2,601
    edited 2008-10-22 04:11
    Sapieha said...
    Hi BradC.

    It is file that produced this error.

    Thanks very much Sapieha, that allowed me to pin it down. I'll have a fix today. In the meantime if you don't enable the listfile output it won't crash.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • mparkmpark Posts: 1,305
    edited 2008-10-22 06:26
    evanh said...
    Umm, It's wrong to call bst a compiler. There is no reconstructing of the program taking place.

    Tokeniser is prolly the best name.

    Umm, no, it's definitely a compiler. Tokenizing is just a small part of what it does.
  • evanhevanh Posts: 16,152
    edited 2008-10-22 09:38
    mpark said...
    Umm, no, it's definitely a compiler. Tokenizing is just a small part of what it does.
    Example?
  • BradCBradC Posts: 2,601
    edited 2008-10-22 09:38
    Ok, 0.08 up with the bugfix for the fault Sapieha found.

    This would only manifset itself if
    A) listfile generation was enabled
    B) the last line of the source file was source code
    C) the last line of the source file was not terminated with a CR/LF or combination of

    Not a required upgrade unless you hit this one specifically.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • BradCBradC Posts: 2,601
    edited 2008-10-22 09:42
    evanh said...
    mpark said...
    Umm, no, it's definitely a compiler. Tokenizing is just a small part of what it does.
    Example?

    I fully agree with mpark here in that spin syntax does not map directly to spin bytecode. There are a number of cases which require you to generate bytecode in a context sensitive fashion.
    It's a combination of a compiler/assembler/linker really.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • evanhevanh Posts: 16,152
    edited 2008-10-22 09:50
    Conditional tokenising or macroing?
  • BradCBradC Posts: 2,601
    edited 2008-10-22 09:52
    evanh said...
    Conditional tokenising or macroing?
    conditional tokenising

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • SapiehaSapieha Posts: 2,964
    edited 2008-10-22 11:15
    Hi BradC.

    I have mentioned on Homespun thread alternate HEX code listing for PASM.
    It is posible for You to have that listing?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer.
    Don't guess - ask instead.
    If you don't ask you won't know.
    If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


    Sapieha
  • evanhevanh Posts: 16,152
    edited 2008-10-22 11:34
    BradC said...
    conditional tokenising
    Ok, I'll put it this way. Since the one thing bst doesn't do is compile code, calling it a compiler is wrong.
  • AribaAriba Posts: 2,690
    edited 2008-10-22 12:06
    @evanh
    From Wikipedia:
    "A compiler is a computer program (or set of programs) that translates text written in a computer language (the source language) into another computer language (the target language)...."

    bstc compiles a Spin source code to a Spin byte code, and includes also a Propeller Assembler.

    @BradC
    I'm really impressed of your work (and also of mpark's work, but I like it more if no .NET framework is needed).
    With the DAT (assembly) listing your bstc is now perfect suited for a source code debugger (like PASD, but also for Spin).

    Andy
  • Cluso99Cluso99 Posts: 18,069
    edited 2008-10-22 12:32
    @Ariba: I have done a Pasm and Spin debugger (zero footprint) and the output listings of both Brad and Michael's compilers are great to do a source code debugger along the lines of your PASD.
  • mparkmpark Posts: 1,305
    edited 2008-10-22 13:59
    Evanh, maybe you should tell us what you think compiling is, since you seem to be using a definition different from the generally accepted one.
  • evanhevanh Posts: 16,152
    edited 2008-10-22 19:27
    Ariba said...
    From Wikipedia:
    "A compiler is a computer program (or set of programs) that translates text written in a computer language (the source language) into another computer language (the target language)...."

    bstc compiles a Spin source code to a Spin byte code, and includes also a Propeller Assembler
    The key word is "another".

    The Spin interpreter is the same language as the Spin source. The Cog machine code is the same language as it's Assembly. There is no other computer language to convert to.
  • AribaAriba Posts: 2,690
    edited 2008-10-22 19:57
    evanh

    The bytecode is not a direct representation of the Spin source code. The bytecode interpreter is like a virtual CPU (or generaly a virtual machine). If you look at a listing, made with bstc, then you will see, that a source command is translated to several bytecode instructions, which together build the Spin command. And an other combination of the same bytecodes build then another command.
    So the bytecodes are low level instructions, comparable with an assembly language, but shurely better fitted to the Spin language.

    I also do not agree with the statement (not from evanh), that Spin is an Interpreter language, and the interpreter fits in the 496 cog ram longs. Spin is a compiler language, that uses an intermediate bytecode, which is executed by a virtual machine in a cog. This is near to the Java approach.

    Andy
  • evanhevanh Posts: 16,152
    edited 2008-10-22 20:39
    Ok, good nudge. [noparse]:)[/noparse] I should have looked before.

    I grabbed a copy of bstc and compiled the example (Ch3-Ex02)-Output.spin. It's very small with a loop and waitcnt. Both commands generated suitably complex code to be called another language. Eg: There was four separate operations to execute the waitcnt: stack Delay, stack CNT, add, waitcnt.

    Agreed. Spin is indeed compiled to bytecode. My mistake.
  • evanhevanh Posts: 16,152
    edited 2008-10-22 20:43
    I ASSumed ... and now just a tad embarrassed.
Sign In or Register to comment.