Page 1 of 1
[SOLVED] What's the proper way to define macro in YASM?
Posted: Sat Aug 16, 2014 4:05 am
by Roman
That's my macro for halting the CPU:
Code: Select all
%macro cpu_halt 0
cli
hlt
%endmacro
And when I call it nothing happens:
Code compiles without any warning, but CPU doesn't halt.
Re: What's the proper way to define macro in YASM?
Posted: Sat Aug 16, 2014 4:16 am
by iansjack
So, what does the assembled code look like?
Re: What's the proper way to define macro in YASM?
Posted: Sat Aug 16, 2014 4:24 am
by Roman
iansjack wrote:So, what does the assembled code look like?
I added this to check.
Code: Select all
mov ax, [blah]
cli
hlt
...
...
...
blah:
cpu_halt
AX == 4dbe
It's strange, because CLI & HLT should be 0xFA & 0xF4.
Re: What's the proper way to define macro in YASM?
Posted: Sat Aug 16, 2014 4:56 am
by Combuster
yasm manual wrote: -Worphan-labels: Warn on labels lacking a trailing option
When using the NASM-compatible parser, causes Yasm to warn about labels found alone on a line without a trailing colon. While these are legal labels in NASM syntax, they may be unintentional, due to
typos or macro definition ordering.
Re: What's the proper way to define macro in YASM?
Posted: Sat Aug 16, 2014 4:58 am
by alexfru
"mov ax, [blah]" might probably need to be changed to something like "mov ax, cs:[blah]". At any rate, YASM should be able to generate a listing file, in which you should find the actual instructions from the expanded macros and/or instruction opcodes. Besides, there are disassemblers out there! I don't know if YASM comes with one, but NASM does.
Re: What's the proper way to define macro in YASM?
Posted: Sat Aug 16, 2014 5:12 am
by Roman
Moved the macro to the top of the code, now works.