Hallo Frank,
The error message I got was: "TMP.asm:18: error: parser: instruction expected". But I found out later that that must have been due to a stupid typo I overlooked all the time. This morning I was experimenting a bit again and didn't see it any more until I made another typo.
The experiments brought me further but not with the wanted result. I'm writing a Pascal compiler in Pascal and it generates a source code that does not contain instructions but only macros. An include file should contain the macros with the instructions for the wanted processor. My self written assembler should turn the whole in an executable. So far things go fine with creating programs for example for the Commodore 64.
But I also wanted to be able to create programs that should run on a 8088 machine running my own OS. So I started to add a unit to my assembler that should handle 8088 instructions. But to be able to test the generated code, I wrote a little program that translates various directives into NASM ones. That worked out fine except for my own ".if" directive.
The code of the main program after the translation:
%include 't8088.inc'
CPU 8086
org $0100
;
macJump zFirstLine
; === Constants ===
CONST0000:
db $10,'Hello!'
; === Subroutines needed by macros ===
mDisplayAL
mDisplayString
zFirstLine:
; 3 begin
macWrite StringSym,CONST0000,0,0
macWriteLn
; 4 writeln('Hello!');
; 5 end.
macEndOfProgram
; === Variables ===
The part of t8088.inc that is relevant for the above:
CharSym equ 2
StringSym equ 9
WordSize equ 2
True equ 0FFh
False equ 0
%macro macWrite 4 ; type, address of variable/char, length number(s)
%if True ; works
;%if StringSym=&1 ; doesn't work
mov si,&2
call cDisplayString
%endif
%if WordSize=CharSym ; works
;%if (&1=CharSym) ; doesn't work
;%if &1=CharSym ; doesn't work
;%if False ; works
; mov al,[&2]
mov si,&2
mov al,[si]
call cDisplayAL
%endif
%endmacro
So far I have found out that the %if statements using True and False work fine and the one whith "WordSize=CharSym". But all the ones using &1 in one or another way are not accepted by NASM. Even the one where I expected that "StringSym=&1" would be translated into "StringSym=StringSym" and thus should have worked. But alas, no.
Another question: "mov si,&2" does work, "mov al,[&2]" generates an error. Why?
I hope you can help!
Kind regards, Ruud Baltissen