Shop OBEX P1 Docs P2 Docs Learn Events
p2asm - Page 4 — Parallax Forums

p2asm

124»

Comments

  • @evanh

    I am getting used to your code and am now understanding it.
    Got a question.
    Added a string to print. It looks identical to the others but I now get the following error message:

    cog label must be long aligned.
    If I comment out one of the strings the error goes away.
    Do I have to change from bytes to longs?

    Thanks.
  • evanhevanh Posts: 15,187
    edited 2019-04-28 02:32
    Cool, I did some learning myself while writing those routines.

    Okay, I'm going to give you two answers for that error. First answer is for making the #puts routine work: #puts expects the string to be located in hubram. For that you should use a single ORGH directive ahead of the strings as a group. No need for a specific address, just "ORGH" sorts it. As a side effect, this makes the error go away.

    As a side note, it wouldn't be too hard to make a #cogputs routine as well.


    Second answer is a fix the error with byte data in cogram (This is not for #puts routine). You can either use ALIGNL directives for every string or hand pad the data to multiples of four bytes, eg:
    str1		byte    " test",13,10,0[1]     '8 bytes
    str2            byte   " sucess",13,10,0[3]     '12 bytes
    str3            byte   " working",13,10,0[2]     '12 bytes
    
    
  • evanhevanh Posts: 15,187
    PS: The reason why #puts would have been printing correct strings without a ORGH is because the way the first cog is booted. When the program is loaded from serial port it is placed in hubram starting from address zero. Once the loading is finished a COGINIT is executed to copy the first 2kB of hubram into cogram and then starts executing from zero in cogram.

    At this point there is duplicate copies of the downloaded program in the Prop2. So you can reference the data in either hubram or cogram and see the same. That's what is happening with the #puts routine, it's reading the hubram data that just happens to be identical to the cogram data.
  • @evanh

    Thanks for the help. I am now able to get the multiple strings to work.
    Now attempting to get the decimal stuff to work . Using itod??
    Please see attached.

    Your help has been great. I never understood fullduplexserial until now. Just trying to get the bugs out of my brain and tidy up the code. Wonderful learning experience.
  • evanhevanh Posts: 15,187
    Yep, itod is for printing the decimal representaion of integer in the PA register. It's not any sort of floating-point, in case you may have thought so.

    In terms of the way I've written the routine, I didn't look up any known methods so it may well be long winded in the way it converts from lsb first into a complete string of BCD digits before transmitting as human readable msb ordered.
  • ok thanks
  • RossHRossH Posts: 5,345
    Hi Dave

    Found another issue with p2asm - the "IF_XX" and "IF_NOT_XX" style of instruction prefixes compile ok with PNUT, but they don't compile properly in p2asm - but they also don't give an error.

    For example, try
    DAT
    
    ' these should be the same ...
    
     IF_X0        mov 0,0 
     if_nz        mov 0,0
    
    ' and these ...
    
     IF_00        mov 0,0 
     if_nz_and_nc mov 0,0
    
    ' and these ...
    
     IF_NOT_10    mov 0,0 
     if_nc_or_z   mov 0,0
    
    ' etc ...
    
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-02-27 01:56
    deleted - my bad!
  • error
Sign In or Register to comment.