tgrysztar / fasmg

flat assembler g - adaptable assembly engine
https://flatassembler.net/
216 stars 29 forks source link

Using segment label with some instructions with x86-2 package throw error: variable term used where not expected #19

Open LKMystery opened 3 months ago

LKMystery commented 3 months ago

Example code:

`format MZ

entry code_segment:start

xdata = 0x100

segment code_segment use16

start:

add ax, xdata + 0x100 ; correct mov ax, xdata + 0x100 ; correct

mov ax, data_segment + 1 ; correct mov dx, data_segment + 1 ; correct add dx, data_segment + 1 ; correct add ax, data_segment + 1 ; error : add? [113] Processed: emit size: @src.imm

segment data_segment use16 ` using x86 package compiled it.

I found in file x86-2.inc on line 1347 asm emit size: @src.imm and changed to check size = 2 jyes imm16 asm emit size: @src.imm imm16: call word, @src.imm to get work!

bitRAKE commented 2 months ago

https://github.com/tgrysztar/fasmg/blob/e7c5fa56dbeb6c22612a9feae3bfd46e0659396f/packages/x86-2/x86-2.inc#L1341-L1351

Also present in the fasm2 refactoring, https://github.com/tgrysztar/fasm2/blob/856414cbec0196d41fda36111cb96284bb628ecb/include/x86-2.inc#L1269-L1286