To learn fasmg, I try to re-create x86 architecture
macro x86.parse_operand ns*, operand*
match =byte? value, operand
ns.size = X86_OPERAND_SIZE_BYTE
x86.get_operand_type ns, value
else match =word? value, operand
ns.size = X86_OPERAND_SIZE_WORD
x86.get_operand_type ns, value
else match =dword? value, operand
ns.size = X86_OPERAND_SIZE_DWORD
x86.get_operand_type ns, value
else
ns.size = X86_OPERAND_SIZE_UNDEFINED
x86.get_operand_type ns, operand
end match
end macro
macro x86.get_operand_type ns*, value*
match [addr], value
ns.type = 'mem'
ns.value = +addr
else match segment:offset, value
ns.type = 'farptr'
ns.segment = +segment
ns.value = +offset
match [addr], offset
ns.type = 'mem'
ns.value = +addr
end match
else
ns.type = 'imm'
ns.value = +value ; <<<<<<<<<<<<<<<<<<<
if ns.value eq ns.value element 1
if (ns.value metadata 1) metadata 1 relativeto x86.reg
ns.type = 'reg'
else if ns.value metadata 1 relativeto x86.sreg
ns.type = 'sreg'
end if
end if
end match
end macro
macro add? dest*, src*
;x86.parse_operand _operand1_, dest
x86.parse_operand _operand2_, src
end macro
Marked string throws "Error: illegal instruction" for immediate operand:
. It's not allowed to use variables with the same name (If I change "ns.value" to "ns.imm" orr anything else in the final ELSE clause, then code compiles without errors). But why? 'value' variables, as I see them, are in different namespaces. Could anyone clarify this behavior please?