Shop OBEX P1 Docs P2 Docs Learn Events
How to fill a DAT block conditionally - thanks, problem solved. — Parallax Forums

How to fill a DAT block conditionally - thanks, problem solved.

Cluso99Cluso99 Posts: 18,069
edited 2010-05-05 14:41 in Propeller 1
I have a screen buffer which varies in size. If it is greater than the cog space I need to fill past the end of the cog.

How do I do this only if the size > 496*4. The PropTool compiler fails if the amount to fill is negative (which is when I do not need to fill anything).

Here is the piece of code which fails.

'' ┌──────────────────────────────────────────────────────────────────────────┐
'' │ The following fills cog space in hub + 16 bytes for screen[noparse][[/noparse]2000] space.  │
'' └──────────────────────────────────────────────────────────────────────────┘
                        long    0[noparse][[/noparse]$1F0-$]               'pad to fill cog space (because the screen lives here in hub) 
ends                    FIT     $1F0
                        org     0
                        long    0[noparse][[/noparse]((ocols*orows) -(496*4))/4] 'reserve extra space for screen > cog-size (1984)


The last line fails if (ocols*orows) < (496*4) however I want it to just ignore the command in this case.
If (ocols*orows) > (496*4) I want to reserve the extra bytes/longs.
Any ideas??

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz

Post Edited (Cluso99) : 5/5/2010 9:05:50 AM GMT

Comments

  • potatoheadpotatohead Posts: 10,261
    edited 2010-05-05 05:22
    Try the limit minimum operator?

    Maybe use a multiply in combination with the result of a comparison?

    (((ocols*orows) > (496*4)) & %01) * ((ocols*orows) - (496*4)) + 1

    What I'm thinking is that the comparison will either equal -1 or 0. And that to get just a binary 1 or 0. Multiply the difference between the needed screen memory fill value, and add one, just to keep the whole works positive.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    8x8 color 80 Column NTSC Text Object
    Safety Tip: Life is as good as YOU think it is!

    Post Edited (potatohead) : 5/5/2010 5:34:54 AM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-05-05 05:30
    I assume the screen buffer exists in the hub, right? Why not put the fit ahead of the buffer and just declare the buffer to the size you want. The assembler won't care, and you don't need the extra org either.

    -Phil
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-05-05 06:14
    @potatohead: It is fine to have a resultant size of 0, just not negative.

    @Phil: The buffer begins at the hub address where the cog is loaded from, so I am re-using the hub space after it is loaded into the cog. This works fine, but now I am making the screen buffer size variable so I need to allocate the extra little bit (if screen > 80*25) and I only want to allocate if it is required.

    This is in my Debug 1pin TV * 1pin KBD code and I have almost all calculations now being done by constants so there is minimal overheads. I have also freed quite a bit of cog space for extra VT100 commands.

    I have tried PAL 64*32 (2048) and it works nicely, as does NTSC 64*28, both at 5MHz. There is a little shimmering. 60* is a little better.

    File attached: To archive I had to comment out the offending line in "Debug_1pinTV_rr051g.spin"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • potatoheadpotatohead Posts: 10,261
    edited 2010-05-05 06:31
    Well, then the multiply should work as is, no addition needed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    8x8 color 80 Column NTSC Text Object
    Safety Tip: Life is as good as YOU think it is!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-05-05 06:49
    Something like this works:

    [b]CON[/b]
    
      BUF_LONGS     = 100
    
    [b]PUB[/b] start
    
      [b]cognew[/b](@my_cog, 0)
      [b]longfill[/b](@buffer, 0, BUF_LONGS)
    
    [b]DAT[/b]
    
                  [b]org[/b]       0
    buffer
    my_cog        [b]long[/b]      $aaaaaaaa[noparse][[/noparse]*200]          'This is the program.
                  [b]fit[/b]
                  [b]long[/b]      $55555555[noparse][[/noparse]&#173;(BUF_LONGS - $) & (BUF_LONGS > $)&#093;
    
    


    Vary the size of BUF_LONGS, and use F8 to view the allocation.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 5/5/2010 6:56:01 AM GMT
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-05-05 09:02
    Thanks Phil & potatohead. Your trick of doing a compare·& value worked cool.gif

    Here is what I did, and I do not have to fill the cog space either if the screen is smaller. A winner all-round.
    xeos                    long    (ocols * orows)         'end of screen
                            FIT     $1F0
    '' &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
    '' &#9474; The following fills cog/hub space (if reqd) for larger screens.          &#9474;
    '' &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;
            long  0[noparse][[/noparse](ocols*orows/4 > $) & (ocols*orows/4 - $)]  'reserve extra space if screen > cog code
    
    



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • potatoheadpotatohead Posts: 10,261
    edited 2010-05-05 14:41
    Nice move on the "&' too. Since all the bits are set, if true, a positive value will result. I've always thought the -1 value for true on Propeller was a quirk. Most computers I've worked with use just '1' for true, making this kind of thing a simple multiply. On some older basics, this kind of expression was faster than 'if -- then', so I ended up using it regularly over the years. Having all the bits set for true, means being free to apply a simple bit operator after the comparison. That's cool!

    The conditional math also helps in CAD. Not all systems offer comparisons and or are limited in syntax. Most will evaluate a comparison though. That's part of the convoluted expression I posted here.

    Using the '&' like you did, eliminates the multiply needed to act on the compare, and makes more general logical sense than a simple value of "1" does to me now. Cool.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    8x8 color 80 Column NTSC Text Object
    Safety Tip: Life is as good as YOU think it is!

    Post Edited (potatohead) : 5/5/2010 3:26:15 PM GMT
Sign In or Register to comment.