KarolS/millfork

Array declaration - request for improvement

zbyti opened this issue · 2 comments

zbyti commented

06e5da4

It would be nice to have:

const word dlAddr = $3000
const word lms1Addr = $4000
const word lms2Addr = $4060
const word lms3Addr = $40c0

array(byte) dl @ dlAddr = [
  $70,$70,$70,
  $52,lms1Addr,
  $52,lms2Addr,
  $52,lms3Addr,
  $41,dlAddr
]

// or

array(byte) dl @ dlAddr = [
  $70,$70,$70,
  $52,lms1Addr.lo,lms1Addr.hi,
  $52,lms2Addr.lo,lms2Addr.hi,
  $52,lms3Addr.lo,lms3Addr.hi,
  $41,dlAddr.lo,dlAddr.hi
]

zbyti commented

OK, I can do this:

array(byte) dl @ dlAddr = [
  $70,$70,$70,
  $52,lo(lms1Addr),hi(lms1Addr),
  $52,lo(lms2Addr),hi(lms2Addr),
  $52,lo(lms3Addr),hi(lms3Addr),
  $41,lo(dlAddr),hi(dlAddr)
]

What you want can also be done with either:

array(byte) dl @ dlAddr = [
  $70,$70,$70,
  $52, @word[lms1Addr],
  $52, @word[lms2Addr],
  $52, @word[lms3Addr],
  $41, @word[dlAddr]
]

or

struct s { byte a, word b }
array(byte) dl @ dlAddr = [
  $70,$70,$70,
  @struct [ 
    s($52, lms1Addr),
    s($52, lms2Addr),
    s($52, lms3Addr),
    s($41, dlAddr) 
  ]
]