Shop OBEX P1 Docs P2 Docs Learn Events
How is assembly code stored — Parallax Forums

How is assembly code stored

Richard S.Richard S. Posts: 70
edited 2007-01-24 01:19 in Propeller 1
If one has an assembly program, how are the instructions stored in memory.· For example the instruction line:

·· MOV·· TEMP, INA

Are the·parts stored sequentially in memory·as MOV, TEMP, INA·· or

are they stored sequentially in memory as INA, TEMP, MOV?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard in Michigan

Comments

  • asterickasterick Posts: 158
    edited 2007-01-23 23:38
    It is stored as a packed 32 bit long value

    the upper 6 bits are a MOV flag, followed by some flags that say that you want to write the result, but not the carry or zero result and that you want to use the data stored at memory location INA instead of a 9bit immediate, followed by 1111 (always execute condition), followed by 2 9bit literals that point to TEMP then INA's memory locations.

    All instructions work off the same 6:4:4:9:9 encoding.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-24 00:09
    The Propeller manual has some nice tables on pages 350 and 351 that show how the bits are laid out in the instructions and what each field is used for.
  • Richard S.Richard S. Posts: 70
    edited 2007-01-24 00:40
    Hmmm...· The reason I asked is because I needed to understand several lines of assembly code in the rotaryencoder.spin file.· John Culver responded with the following:

    ====

    The :PinSrc is the address of the io read instruction (mov st2, inb), not a subroutine. Those 2 instructions are checking if the pin number is in the range 0..31 or 32..63 and modifying the io address accordingly with the·muxc instruction·altering the source of the input read between ina and inb which only differ in their low bit.

    test··· Pin, #$20·············· wc

    · If the pin number is in the range 32..63 the carry is set.· If the pin number is in the range 0..31 the carry is cleared

    muxc··· :PinSrc, #%1

    ··By copying the carry into the low bit of the :PinSrc instruction the instructions source address·gets changed between ina and inb. This replaces the low bit of the address so inb is only used when requested by Pin numbers 32..63.inb will be used if the pin number is 32 or more, ina for 0..31. This should support 64 io pin propellor chips.

    The initial read of the inputs (mov st2, ina)·ought to have had the same self modifying code applied to it, but that's a minor detail.

    RotaryEncoder aka QuadratureEncoder works well as·a 1 to 16·incremental quadrature encoder interface. I have tested it succesfully on actual quadrature encoders. I have faster versions for smaller numbers of encoder incremental interfaces.

    ====

    I understand his explanation.· There are other areas in the assembly code where registers are changed by the program.· It appeared to me that the 'source, destination, instruction'·is the sequence of stored information...since dynamic register changes appear to occur in that order.·

    Does that make sense?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Richard in Michigan
  • Richard S.Richard S. Posts: 70
    edited 2007-01-24 00:45
    Forgot to post the rotaryencoder.spin assembly code for reference.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Richard in Michigan
  • asterickasterick Posts: 158
    edited 2007-01-24 01:19
    Rule of thumb is that 1 assembly instruction = 32 bits (4 bytes) of data. No more, no less. This may change in future versions of the spin IDE if they add literal pooling. The processors operate on an internal 32 bit bus, so it's all loaded and decoded at the same time. (long values are stored in intel order)

    I would agree with Mr. Green in that you should crack out the manual and take a gander.
Sign In or Register to comment.