Thomas Jentzsch Posted April 12, 2021 Share Posted April 12, 2021 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 More sharing options...
+Andrew Davie Posted April 12, 2021 Share Posted April 12, 2021 (edited) 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 Edited April 12, 2021 by Andrew Davie 1 Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 12, 2021 Author Share Posted April 12, 2021 Interesting approach. Thanks! Now we only need something for a large number of symbol variations. Link to comment Share on other sites More sharing options...
+Andrew Davie Posted April 12, 2021 Share Posted April 12, 2021 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 More sharing options...
Thomas Jentzsch Posted April 12, 2021 Author Share Posted April 12, 2021 While this works, it is IMO pretty odd and not easy to understand especially later on. Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 13, 2021 Author Share Posted April 13, 2021 (edited) 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 April 13, 2021 by Thomas Jentzsch Link to comment Share on other sites More sharing options...
Recommended Posts