Skip to content

feature request: (as-data) #1

@dustmop

Description

@dustmop

Would be nice to have a built-in as-data that would add rows to a data segment, returning a handle that can be used later to access it. Example:

  (my-func (as-data 'my-things 1 2 3))
  ...

(defsub (my-func handle)
  (let ((n) (m) (p)
    (set! n (data-access 'my-things handle 0))
    (set! m (data-access 'my-things handle 1))
    (set! p (data-access 'my-things handle 2))
    ...

Which compiles into:

  lda #3
  jsr my_func
  ...

my_things_data_table:
.db 0, 0, 0
.db 1, 2, 3

my_func:
  ldy local_handle
  lda my_things_data_table,y
  sta local_n
  ...  

This is needed for things like opcodes in interpreter tables, and passing large arg lists to certain functions. I have found myself writing half-hearted implementations of this pattern all over the place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions