Tasks
The same steps as the lab slide. Do them on a Linux PC with the files from the zip; the tools below help you check your thinking first.
Lab 4 · Macro Processors
- Build the starter
gcc -Wall -o macro macro_starter.c then ./macro maccnt.asm. The output still says COMP &CH. - TODO 1: DEFTAB
Replace each parameter name by ?n when storing a line. Print DEFTAB and compare with slide 11. - TODO 2 + 3: ARGTAB
Split the call's operand at commas; replace ?n by ARGTAB[n−1], counting down. - TODO 4: the label
Put the call's label on the first generated line. diff with maccnt_expected.asm must print nothing. - Into the assembler
./macro maccnt.asm > m.asm then your Lab 3 ./sicasm m.asm. The object program must match slide 7's run. - TODO 5: $ labels
Make twice.asm work: CNTCH called twice. Without TODO 5 your assembler reports duplicate symbol LOOP.
Submit: macro.c, the expanded twice.asm, and its object program from your Lab 3 assembler.
Try it here
These run in your browser, with no server and no internet. They are built from the same reference programs as the lab, so their output matches what your finished C program should print. They do not replace the real lab: the kernel, gcc and your own code are the point.
Read the files
Every text file from lab04_files.zip. Read here, then download the zip to work on them.