Shop OBEX P1 Docs P2 Docs Learn Events
basic XBYTE questions — Parallax Forums

basic XBYTE questions

I've been spinning my wheels here for too long. I've had more code and less code and it has executed byte_codes and lut_tables and not yet in a way I expect and often forever executing them. I baked this down to the what I think are the essential elements to run a few byte codes. baby steps, I'll try to build on.

ultimately, I'm trying to launch this cog with the byte_codes required to load a Scheme parser/bytecode generator that continues to load the XBYTE interpreter. I've noodled around with starting two adjacent cogs to share a double-sized LUT to cover most of R5RS Scheme bytecodes implemented in Pasm2.

all that may be a fever dream of mine. but, I was hoping someone here would recognize the mistakes I've made in this condensed batch of mistakes, and help me grok what needs to happen. as nifty as it is in other respects, grok.com couldn't help me with this.

I welcome any guidance, comments, even chiding. thanks.

Comments

  • ersmithersmith Posts: 6,193

    You need both the address of the LUT code and the byte code to execute. Some general tips:

    (1) The byte code table (what you call lut_table) must be in LUT, not HUB, so you want something like org $200 in front of it, not orgh $400

    (2) To load code into LUT use setq + rdlong, like:

        loc   pa, #@lut_table ' get HUB address of LUT data + code into pa
        setq2 #$1ff   ' load all of LUT
        rdlong $0, pa ' load to address 0 in LUT
    

    (3) To start xbyte, do something like

     restart_loop
        push    #$1ff       ' start xbyte loop
      _ret_ rdfast  #0, pb      ' use table at start of LUT, read bytecodes from address in pb
        jmp #restart_loop
    

    This assumes that the opcode table starts at $0 in LUT, and the actual implementation of the opcodes follow it.

    (4) The code executed for each bytecode must be in COG or LUT memory. Running code from HUB interrupts the XBYTE loop; it is possible to do this and get back into XBYTE, but it's slightly tricky so don't try to do this at the start.

  • Hi
    I am not at my PC now, but perhaps some comments.

    I am not sure, if you can double space for LUT in this way. I think the address space is mapped onto the own Lut. ??

    But the code of the xbyte interpreter can call code in hub. It must be restarted then.

    There is a tile vga driver in the examples of Flexspin, which shows how to load and start a extra cog with code and data in cog and lut.

    A simpler driver with parameters in a separate cog is for ws2812 by Jon in obex.

    I find Chip's example for the xbyte mechanism in the doc helpful.

  • @ersmith @"Christof Eb." thanks for wading into this when I didn't even know the question I was asking.

    you've prompted me to understand the memory layout better and that has helped overall. and I'm reminded to go all the way back to Chip's example, which I had running at one point in this adventure, and add and adjust from there without getting too far ahead ... more commits to the repo.

    thanks again.

Sign In or Register to comment.