flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > [fasmg] Cannot generate code for jz macro |
Author |
|
revolution 01 Mar 2017, 16:42
That appears to be the same problem as this:
https://board.flatassembler.net/topic.php?p=178826#178826 There is no solution unless you force the longer encoding with a small sized offset. You will have to change the macro to detect it. Maybe create a new variable that keeps track of previous passes attempts. Or perhaps change the "else" block to create two bytes of dummy data to match the other block. |
|||
01 Mar 2017, 16:42 |
|
Tomasz Grysztar 01 Mar 2017, 17:00
Actually in this specific case there is a simple solution. Compare how is it done in examples/x86/include/8086.inc:
Code: macro x86.short_jump opcode,dest x86.parse_jump_operand @dest,dest if @dest.type = 'imm' & ( @dest.jump_type = 'short' | ~ @dest.jump_type ) if @dest.imm relativeto 0 & (@dest.imm < 0 | @dest.imm >= 10000h) err 'value out of range' end if db opcode if @dest.imm-($+1)<80h & @dest.imm-($+1)>=-80h db @dest.imm-($+1) else err 'relative jump out of range' db ? end if else err 'invalid operand' end if end macro Code: macro jz? dest* local addr addr = dest - $ - 2 db 01110100b if addr >= -128 & addr < 128 db addr else err asmerr_jmp__outof_range db ? end if end macro NNN = 128 lbl_a: db 6 jz lbl_a jz lbl_b db NNN dup 0 lbl_b: |
|||
01 Mar 2017, 17:00 |
|
zhak 01 Mar 2017, 17:13
Yeah, adding a tracking variable did the trick, thanks!
|
|||
01 Mar 2017, 17:13 |
|
zhak 01 Mar 2017, 17:19
Thank you for the explanation, Tomasz. Without it that db ? part in your macros would remain unclear
|
|||
01 Mar 2017, 17:19 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.