Shop OBEX P1 Docs P2 Docs Learn Events
Propeller 2 Assembly Language beginner guide v0.1 - Page 2 — Parallax Forums

Propeller 2 Assembly Language beginner guide v0.1

2»

Comments

  • @evanh

    Thank you

  • proppyproppy Posts: 50
    edited 2026-05-24 02:40

    Holy moly! I've been away for a bit but wow, thanks everybody for the out pouring!

    @"Christof Eb." said:
    Hi @proppy !
    this is a nice effort, thank you!

    I wonder, if some example of an inline section of propeller asm would be helpful. I think, most people will want to start with rather tiny routines embedded in some other high level code to have maximum speed there.

    Christof

    Hi @"Christof Eb." . Let me look into it. Honestly, bridging that gap might be pretty helpful for Spin2 at the very least.

    @pilot0315 said:
    @proppy

    I too will be headed to the print shop.
    Thank you for this effort.
    When do you think the examples and maybe some videos will be on github??
    Martin

    Hi @pilot0315.

    The examples should be on the github for all the examples in the manual. I started doing TikTok for the videos. Right now it's just text videos but the idea is to get some TikTok videos of the terminal/explaining code via TikTok Live. It allows me to clip stuff so I could make videos as well as run Live code cast.
    https://www.tiktok.com/@p2assembly

    @pilot0315 said:
    @proppy
    I assume that I can bleed some of this over to Pasm??
    Thank you and Evan.
    Martin

    Mostly, the only differences are in the way the cogs work between them, smart pins, hub access speed, etc. I may circle around

  • pilot0315pilot0315 Posts: 1,006
    edited 2026-05-24 04:59

    @proppy

    Thanks I will go back to github and look again. Found them on github. Tried the first one to print and then add. On propeller tool and on spin tools. Neither gives me anything. Checked the baudrate and even changed it 115200 just for giggles and got nothing.
    Using p2 eval rev b and c. Will try one of my edge devices and let you know.
    Thanks
    I checked the copy paste line by line.
    Martin

  • @pilot0315 said:
    @proppy

    Thanks I will go back to github and look again. Found them on github. Tried the first one to print and then add. On propeller tool and on spin tools. Neither gives me anything. Checked the baudrate and even changed it 115200 just for giggles and got nothing.
    Using p2 eval rev b and c. Will try one of my edge devices and let you know.
    Thanks
    I checked the copy paste line by line.
    Martin

    I had upgraded the example a bit ago. A few folks pointed out the same. I added jmp #$ and tested on a few setups other than FlexProp, which originally had zero issues. Let me know, at this point I'm just making vids so things have slowed down a bit and it's mostly just edits on the manual itself and including the suggestions. Thank you so much!

  • Thanks @proppy
    Martin I will let you know.

  • @proppy

    'print_character.spin2
    CON
    _CLKFREQ = 180_000_000
    BAUD_RATE = 2_000_000
    TRANSMISSION_PIN = 62
    BIT_PERIOD = (_CLKFREQ / BAUD_RATE)
    BAUD_MODE = (BIT_PERIOD << 16) | (8 - 1)

    DAT
    org 0
    asmclk

    dirl #TRANSMISSION_PIN
    wrpin ##(P_ASYNC_TX | P_OE), #TRANSMISSION_PIN
    wxpin ##BAUD_MODE, #TRANSMISSION_PIN
    dirh #TRANSMISSION_PIN
    wypin #1, #TRANSMISSION_PIN

    mov character, #"A"
    wypin character, #TRANSMISSION_PIN

    endprog
    jmp #$

    character res 1

    String:

    'send_string.spin2

    both files say last month.
    Tried in Pnut53 get lost hardware.
    Tested with Pnut 53 examples no issues.

    Tried also on Propeller tool and blank screen as well as Spin Tools ide.
    ????????????

    Tested all with existing code and they work.

    Sorry to bother you.
    Martin

    BTW. The book you wrote as I keep reading I really understand that is the great part.

  • proppyproppy Posts: 50
    edited 2026-05-26 22:15

    @pilot0315 said:
    @proppy
    Sorry to bother you.
    Martin

    BTW. The book you wrote as I keep reading I really understand that is the great part.

    It's not a bother at all really. I have been told I need to make sure things work across the board before. :) And thank you for the compliment.

    I tried the code under Spin Tools IDE, it works. I also tried it under FlexProp and it seemed to work as well. I am using the P2 edge setup. Is your Parallax Serial Terminal set to 2000000 by chance? The baud rate in the code is set to 2_000_000. The terminal should be set the same. I included a screenshot.

    Feel free to include screenshots. :) Also, can you describe your setup? Win, Linux, Mac? Emulator like WINE?

    EDIT: Also can you try the following? It has a waitx after the smartpin startup. I set the baud rate to 115_200, a much lower rate, just to test something I thought of.:

    CON
        _CLKFREQ = 180_000_000
        TRANSMISSION_PIN = 62
        BAUD_RATE  = 115_200
        BAUD_MODE = ((_CLKFREQ / BAUD_RATE) << 16) | (8 - 1)
    
    DAT
            org     0
            asmclk
    
            dirl   #TRANSMISSION_PIN
            wrpin  ##(P_ASYNC_TX | P_OE), #TRANSMISSION_PIN
            wxpin  ##BAUD_MODE, #TRANSMISSION_PIN
            dirh   #TRANSMISSION_PIN
    
            waitx ##10_000_000
    
    
            wypin  #"A", #TRANSMISSION_PIN
    
            jmp    #$
    
  • pilot0315pilot0315 Posts: 1,006
    edited 2026-05-28 07:57

    @proppy

    I checked the baud rates for all three GUI. I even changed the baud rate just for fun in the code and the terminals.
    Nothing. Not even gibberish that you would see if the baud rates are not in sync.
    Just nothing.
    I will try with one of my edge boards and let you know.
    The above code works with a P2 eval RevB instantly. I will play and adapt the other code examples and let you know. :)
    Also checked it with the 2_000_000 baud and it works great also. For fun added a loop and I gets forever "A" 's printing.
    Thanks
    Martin.
    Got the printed version in my hand now. Drooling over it. :DB)

    Lastly I inserted the waitx before the wypin #1, #transmission_pin in the multiplication code and it now works also. Must be the smartpin as you said needing time to set up.
    Using Windows 11 pro.

  • @pilot0315 said:
    @proppy
    Lastly I inserted the waitx before the wypin #1, #transmission_pin in the multiplication code and it now works also. Must be the smartpin as you said needing time to set up.
    Using Windows 11 pro.

    Yes, correct. I've run into this a few times until i settled on the code in the GitHub. The delay, waitx in the second code, helps because you are dealing with toolchain startup timing, cog scheduling, smart pin enablement and any terminal delays. It might be one of these things or it could be all of them honestly.

    So, "waitx" and "wypin #1, pin" are forcing an active state. They do it in different ways, indirectly(waitx) and directly(wypin). Personally I prefer not to use delays like waitx or nop. But, you'll find when you get to attach other hardware that you'll need said delays. The flash on the P2 edge is one example.

  • @proppy

    Understood. I am 70 and began coding when I was 16. Basic, Fortran, hated Cobol. IBM 1130 and 360 plus some others.
    Got back into it 15 years ago with Parallax. Wonderful help. Now we have toys to play with. Like GPS.
    Always wanted to learn ASM.
    This is the perfect opportunity. I will send you a personal link with more info.
    Thanks
    Martin

  • pilot0315pilot0315 Posts: 1,006
    edited 2026-05-29 05:52

    @evanh said:
    In the "WAITX vs NOP" topic you mention that instructions execute in one clock cycle. This is incorrect, base instruction execution takes two clock cycles.

    I do wonder where your info is coming from? ChatGPT maybe?

    EDIT: Ah, maybe some of this pertains to very early FPGA development where it was indeed an instruction per clock. That became known as the Prop2-Hot design. Which would probably explain the simclk reference as well.

    For future documenting, anything you find prior to year 2020 can be discarded as not valid for finished Prop2 chips.

    I read what evanh said and increased the waitx to 40 000 000 it appears to work better. I think this covers for the two clock cycles. Remember reading this somewhere.

  • If the second question about ascii is in the earlier comment please disregard figured it out.

  • @pilot0315 said:
    @proppy

    Understood. I am 70 and began coding when I was 16. Basic, Fortran, hated Cobol. IBM 1130 and 360 plus some others.
    Got back into it 15 years ago with Parallax. Wonderful help. Now we have toys to play with. Like GPS.
    Always wanted to learn ASM.
    This is the perfect opportunity. I will send you a personal link with more info.
    Thanks
    Martin

    Sounds good. And this started off as kind of a throw it at the wall project. But thanks to you and others I have many more improvements that will help folks. I'm going to add the delay stuff we talked about in an appendix of gotchas. So truly thank you because this will help the next person deciding if they want to learn some p2asm. I use to do z80 and 6502 but honestly p2asm is probably the most relaxing assembly I have ever encountered. Even the cog lock stuff was simple to understand. I'm mostly just getting videos together so I'll be checking this and updating the manual in the coming months. Feel free to post any you think it note worthy to add. Right now it's just about where to place stuff so it remains beginner friendly.

  • RaymanRayman Posts: 16,445

    Flexspin lets you inline assembly on P1

    Just fyi…

Sign In or Register to comment.