Shop OBEX P1 Docs P2 Docs Learn Events
Building a DATA table in SXB — Parallax Forums

Building a DATA table in SXB

RS_JimRS_Jim Posts: 1,771
edited 2009-01-19 21:26 in General Discussion
Hi,
I am trying to build a data table with a series of 4 digit numbers. I would like to retrieve each entry·as a word with two digits in each byte.· However, when I enter the data in the form of:
WDATA 0175.0249,etc the compiler is giving me:
0075 0001 0049 0002 etc.· I have tried entering it as 75,01,49,02 etc and I have tried $0175,$0249 etc
Each time the compiler gives me back two words with leading 0.· What is the secret of building this table?

Jim

Comments

  • ZootZoot Posts: 2,227
    edited 2009-01-18 06:06
    If you are using WREAD in SX/B then it will work. The reason you are seeing "leading zeros" in compiler output is because instructions and data statements on the SX are actually 12 bits. In the case of SX/B data the upper 4 bits are not used. So a "Word" data chunk is actually two 12 bit data instructions, where only the lower 8 bits of each are used.

    So if the "Word" data I wanted to write (say it was BCD numbers) is:

    $1776

    I would expect to see two 12 bit instructions in the compiler output:

    DW $076 ' upper 4 bits of instruction = 0, lowest 8 bits are the low byte of my "Word" data
    DW $017 ' upper 4 bits of instruction = 0, lowest 8 bits are the high byte of my "Word" data

    In assembly and in SX/B 2.x there are strategies for using the whole 12 bits in cases where 12 bits is enough but 8 bits are too few. Or if you want to really "compact" Data by stuffing three 16 bit words into four data instructions (a savings of two instructions).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • BeanBean Posts: 8,129
    edited 2009-01-18 13:21
    Jim,
    If you post your code that would help alot.
    It sounds to me like you want:

    DATA 75,01,49,02 ' Note this is NOT WDATA

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ·The next time you need a hero don't look up in the sky...Look in the mirror.


    ·
  • RS_JimRS_Jim Posts: 1,771
    edited 2009-01-19 19:43
    Thanks for the imput guys, Zoot i get invalid command when I try to use WREAD.· I did however run my program under debug and read would return the low byte first and the high byte second so my worries were for naught!
    Jim
    ·
  • ZootZoot Posts: 2,227
    edited 2009-01-19 21:26
    Sorry, brain fart -- I meant if you have WDATA statements and use READ into a Word variable, it will work. As you found out. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
Sign In or Register to comment.