Shop OBEX P1 Docs P2 Docs Learn Events
0-0 (updated to MOVS and self modifying code) — Parallax Forums

0-0 (updated to MOVS and self modifying code)

parskoparsko Posts: 501
edited 2008-07-03 06:21 in Propeller 1
Mike Green and Desilva have used this in misc code, mostly when looking up data in tables in Assembly code. I'd like to write to a table, and am trying to figure out what "0-0" is?

-Parsko

Post Edited (parsko) : 7/3/2008 2:16:34 AM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 01:41
    It's just a placeholder and is used because something like just "0" might be misinterpreted.
    "0-0" is something that will be replaced by something else before that line is executed.

    This is a notation that's been around for many years. I learned it 40 years ago.

    Post Edited (Mike Green) : 7/3/2008 1:47:09 AM GMT
  • parskoparsko Posts: 501
    edited 2008-07-03 01:50
    DAT
              org
    
     
              mov     ptr, #2   'Get second item in table
              call    look
    
    
    look       mov    temp,ptr
               add    temp,#table    ' input value in ptr (0 to n-1)
               movs   :inline,temp   ' have to use instruction modification
               nop                   ' need pause here for future pipelining
               
    :inline    mov    data,0-0       ' get long value from table
               test   ptr,#1   wz    ' do we want odd or even half
        if_z   and    data,mask      ' if even, take lower 16 bits
        if_nz  shr    data,#16       ' if odd, take upper 16 bits
    look_ret   ret
    
    
    
    
    mask       long   $FFFF
    table     word    $0000
              word    $C0C1
              word    $C181
              word    $0140
              word    $C301
              word    $03C0
              word    $0280
    data      res     1
    ptr       res     1
    
    



    So, in this previous code, why is it used?

    Yes, I'm trying to learn about the MOVS command now... I'm confused over where it's MOVS'n temp to, the source location of data? Aka, to these:
    0000_0000 0000_0000 0000_000X XXXX_XXXX (the lower 9 bits)???

    Thanks mike, I thought it was something like that.

    -LUke
  • parskoparsko Posts: 501
    edited 2008-07-03 01:51
    Goes from 30 to 40, huh? Showin that age, huh mike??? [noparse]:)[/noparse] [noparse]:)[/noparse] [noparse]:)[/noparse]

    Parsko was born in '77!!!! That nomenclature has been in your head more than my head has been.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 02:01
    In the example you show, the instruction at :inline is modified by the instruction at look+2. The MOVS copies its operand to the source field portion of the long word at look+2 which happens to be the source field of the instruction at :inline. For the Propeller, this is the only realistic way to do array subscripting. You compute the address you need, then store it in either the source field or destination field of an instruction that uses that address to do something.

    I worked for a calculator / accounting machine company for a year or so. They were just getting into drum memory computers and you had to do the same sort of thing. There was only an accumulator for a register (and a track select register). The next instruction was whatever happened to be under the read head when the CPU was in its fetch phase. You could switch tracks at any time and you could delay until the right instruction came up. Programming was as much timing diagrams as anything.
  • parskoparsko Posts: 501
    edited 2008-07-03 02:12
    I think I see. I read Desilva's tutorial last night, and I see why self-modifying code is needed now, arrays in assembly. I was confused about it last night, and I'm still a bit confused about it tonight. I need to run through a few examples to get the full concept down.

    Does it matter what is in the <#>Value field (from MOVS Destination, <#> Value) in the example? Aka, can 0-0 be #16 or "W" and the instruction will still read $C0C1 from the table into "data"?

    Thanks again. I think, after an answer from that last question, that I'll be good.

    Drum memory computers? Us whipper-snappers must be lucky to have things like 2GB SD cards!

    -Luke
  • parskoparsko Posts: 501
    edited 2008-07-03 02:18
    I think this is also a reason to use the colon in ":inline". I've never seen a need for it before, but this seems to be one.
  • parskoparsko Posts: 501
    edited 2008-07-03 02:40
    Me said...
    Does it matter what is in the <#>Value field (from MOVS Destination, <#> Value) in the example? Aka, can 0-0 be #16 or "W" and the instruction will still read $C0C1 from the table into "data"?
    Nope. I just did it, and you can put whatever you want in there, and it will still read where you point it in the table to read.

    This is very cool.

    See attached example. It uses pin 12 for TV, which should be standard...

    -Luke
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-07-03 04:01
    Mike Green said...
    This [noparse][[/noparse]the 0-0] is a notation that's been around for many years. I learned it 40 years ago.
    Mike,

    I'll bet you've done some IBM 1130/1620 programming! IBM's usual notation for self-modified parameters was *-*, where "*" was shorthand for the current instruction address. Had Chip enabled the current instruction pointer "$" sooner, I suspect that $-$ would have caught on as the preferred notation for the Propeller as well.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 04:01
    The use of a colon for a label prefix makes that label a "local label". This is a way to be able to reuse the label over and over again which is handy for Propeller assembly code where the label is needed within a few lines of code, but it doesn't matter what it is to other sections of the code. One way to do this internally is to keep a counter inside the assembler and to increment it every time an ordinary (global) label is defined. When the assembler finds a colon as the first character of a label, it substitutes the counter value for the colon and processes the resulting label like any other.
  • Cluso99Cluso99 Posts: 18,069
    edited 2008-07-03 06:21
    Drum memory.. brings back memories, just like core memory and the old bootstrap with switches, punched cards, etc cool.gif
Sign In or Register to comment.