flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
zicklag 22 May 2025, 00:21
I'm using the excellent mos 6502 instruction macros to make an NES game with fasmg, and I'm really liking it so far!
One inconvenient thing I'm running into, though, is that I often need to extract the low and high bits from the address of a label. I made a little macro that would help me do that with a custom instruction for assigning low and high variables, but it's not very readable to use. Code: macro low_byte name, value* name = ( value ) and $FF end macro macro high_byte name, value* name = ( ( value ) shr 8) and $FF end macro macro high_low_bytes high_name*, low_name*, value* high_byte high_name, value low_byte low_name, value end macro I saw somebody add an instruction that defined a label and automatically added `.lo` and `.hi` labels using the defined label as a namespace, which seems like a great idea, but I'd like to be able to do that across the whole project for any label. Another possibility might be to add the `<` and `>` syntax that I've seen in other assemblers that allow you to reference the low or high byte of a label when passing it into the instruction. I think that'd require modifying the 6502 assembler macros I'm using. Has anybody else needed to do anything similar and had any solutions they liked?[/code] |
|||
![]() |
|
Tomasz Grysztar 22 May 2025, 03:43
zicklag wrote: I saw somebody add an instruction that defined a label and automatically added `.lo` and `.hi` labels using the defined label as a namespace, which seems like a great idea, but I'd like to be able to do that across the whole project for any label. Code: struc ? definition& . definition .lo := $ and 0FFh .hi := ($ shr 8) and 0FFh end struc my_label: db my_label.hi, my_label.lo Code: include 'inline.inc' inlinemacro lo(value) return = (value) and 0FFh end inlinemacro inlinemacro hi(value) return = ((value) shr 8) and 0FFh end inlinemacro my_label: db hi(my_label), lo(my_label) |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.