hlorenzi / customasm

💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Apache License 2.0
719 stars 56 forks source link

bank start/end/firstfree symbols #195

Open justarandomgeek opened 10 months ago

justarandomgeek commented 10 months ago

I'm trying to use the "leftover" range in a bank to implement a dynamic memory allocator, and it would be handy to have symbols for the bank's start/end addresses, and the first unused address from it. It's pretty easy to fake start and first-free with properly placed labels, but i haven't found a way to get the bank's size or end address as a symbol other than hardcoding it, or putting a symbol in the adjacent unrelated bank.


#bankdef data
{
  #bits 32
  #addr 0x0c00
  #size 0x7400
}

#bankdef program
{
  #bits 32
  #addr 0xa000
  #size 0x2000
  #outp 0
}

#bank data
; *some* of `data` is allocated now...
foo: #res 1
bar: #res 1
;... etc

#bank program
; ... but later on i want to use "the rest"
  ld __data_firstfree, rA ; address
  ld __data_end - (__data_firstfree), rB ; size...?