Jump to content

Open Club  ·  60 members

DASM
IGNORED

Conditional symbol definitions


Thomas Jentzsch

Recommended Posts

Instead of doing this ...

  IF SWITCH = 0
SYMBOL = 7
  ENDIF
  IF SWITCH = 1
SYMBOL = 10
  ENDIF
  IF SWITCH = 2
SYMBOL = 15
  ENDIF

... I am looking for an easier way. Something like ...

ARRAY = 7, 10, 15
SYMBOL = ARRAY[SWITCH]

would be nice.

 

Is there something like this existing in DASM?

Link to comment
Share on other sites

Mmh. How about using operators?

Works for a small # symbols.

SWITCH = 0   ; or 1 or 2
ARRAY = $0F0A07
SYMBOL = ((ARRAY >> (8*SWITCH)) & $FF

It works up to the size of numbers held by dasm.

Perhaps, though, you could extend this by using the string functions

Not quite sure how they work though :P

 

 

Edited by Andrew Davie
  • Thanks 1
Link to comment
Share on other sites

You can change it so the shift = next power of 2 up from maximum # symbols.

And then you can squash lots more in.

For the given example, 0/1/2, then we need 2 bits, so the shift is 2.

Building the array is a bit trickier...

 

ARRAY = (SYM1<<4)|(SYM2<<2)|(SYM3<<0)
... where SYM1..SYM3 are values in the range 0..2

 

 

 

 

Link to comment
Share on other sites

19 hours ago, Andrew Davie said:

It works up to the size of numbers held by dasm.

Unfortunately 32 bit is the limit here.

 

If expressions would all access to generated code, one could create tables in uninitialized segments and read from these. 

Edited by Thomas Jentzsch
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...