Hi Everyone,
I want to implement the macro expanding feature in java, the project description are
Desription:
Write a program to simulate the first phase of an assembler that provides a macro feature. Your program should read in an assembly program that has macro definitions and macros in use. Your program should remove the macro definitions and expand them wherever they are used in the file.
For example:
MACRO COPY $0 $1
MOV AL,$0
MOV $1,AL
ENDMACRO
JMP start ; Jump to 'start' (main code)
DB 30 ; Data table
DB 31
DB 32
DB 33
DB 34
DB 35
DB 36
DB 37
DB 38
DB 39
ORG 20 ; Assembler directive - start of main code
start: ; label
COPY [02],[C0]
COPY [03],[C1]
COPY [04],[C2]
COPY [05],[C3]
COPY [06],[C4]
COPY [07],[C5]
COPY [08],[C6]
COPY [09],[C7]
END
Would be translated to:
JMP start ; Jump to 'start' (main code)
DB 30 ; Data table
DB 31
DB 32
DB 33
DB 34
DB 35
DB 36
DB 37
DB 38
DB 39
ORG 20 ; Assembler directive - start of main code
start: ; label
MOV AL,[02]
MOV [C0],AL
MOV AL,[03]
MOV [C1],AL
MOV AL,[04]
MOV [C2],AL
MOV AL,[05]
MOV [C3],AL
MOV AL,[06]
MOV [C4],AL
MOV AL,[07]
MOV [C5],AL
MOV AL,[08]
MOV [C6],AL
MOV AL,[09]
MOV [C7],AL
END
Tips:
You may use any reasonable macro definition scheme you wish to use. Ensure it can cope with macros with 0 to 5 arguments. Your program is purely a text processor that expands macros. The assembler in the simulator can handle the running of the transformed code.
Your help will be highly appreciated.
Thanks
Regards
cheelemg