Homework # 3
Date: Novomber 17, 1998 Due Date: Novomber 24, 1998
Question 1 (3- pp. 218) (26 Points)
One method of eliminating the displaying the expansions of macros from the listing file is as follows:
When the macro processor encounters a macro
invocation statement, it writes that statement with a special symbol, e. g. +, in column 1
in the source
file without expansion. Later when the assembler assemble that
statement, which is recognized by the special symbol in column 1, it does two things:
So, the process of expanding a macro is done by the assembler not the macro processor.
Question 2 (3- pp. 220) (22 Points)
To include the generation of unique labels we need to modify procedure GETLINE in the algorithm of Figure 4.5 as follows: (modification is shown in bold)
Procedure GETLINE
begin
if EXPANDING then
begin
get next line of macro definition from DEFTAB
substitute arguments from ARGTAB for positional notation
if there is a label which starts with $ then
replace the $ in that label by $ZZ*
end {if}
else
read next line from input file
end{GETLINE}
* ZZ is a two character prefix that
changes with each new invocation of the macro. It can be generated either in procedure
GETLINE or in procedure
EXPAND
Question 3 (12- pp. 222) (32 Points)
a) RDBUFF F1, BUFFER, LENGTH, (04,12)
30 |
CLEAR |
X |
CLEAR LOOP COUNTER |
|
35 |
CLEAR |
A |
||
45 |
+LDT |
#4096 |
SET MAX LENGTH = 4096 |
|
50 |
$AALOOP |
TD |
=X'F1' |
TEST INPUT DEVICE |
55 |
JEQ |
$AALOOP |
LOOP UNTIL READY |
|
60 |
RD |
=X'F1' |
READ CHARACTER INTO REGISTER A |
|
65 |
COMP |
=X'000004' |
||
70 |
JEQ |
$AAEXIT |
||
65 |
COMP |
=X'000012' |
||
70 |
JEQ |
$AAEXIT |
||
75 |
STCH |
BUFFER,X |
STORE CHARACTER IN BUFFER |
|
80 |
TIXR |
T |
LOOP UNLESS MAXIMUM LENGTH |
|
85 |
JLT |
$AALOOP |
HAS BEEN REACHED |
|
90 |
$AAEXIT |
STX |
LENGTH |
SAVES RECORD LENGTH |
b) LABEL RDBUFF F1, BUFFER, LENGTH, 00
30 |
LABEL | CLEAR |
X |
CLEAR LOOP COUNTER |
35 |
CLEAR |
A |
||
45 |
+LDT |
#4096 |
SET MAX LENGTH = 4096 |
|
50 |
$AALOOP |
TD |
=X'F1' |
TEST INPUT DEVICE |
55 |
JEQ |
$AALOOP |
LOOP UNTIL READY |
|
60 |
RD |
=X'F1' |
READ CHARACTER INTO REGISTER A |
|
75 |
STCH |
BUFFER,X |
STORE CHARACTER IN BUFFER |
|
80 |
TIXR |
T |
LOOP UNLESS MAXIMUM LENGTH |
|
85 |
JLT |
$AALOOP |
HAS BEEN REACHED |
|
90 |
$AAEXIT |
STX |
LENGTH |
SAVES RECORD LENGTH |
Question 4 (19- pp. 223) (20 Points)
a) RDBUFF F3, BUF, RECL, ZZ {illegal value specified for &EOR}
This error will be detected by the assembler during the assembly of line 40 since ZZ is not a hexadecimal digit.
40 LDCH =X'ZZ'
b) RDBUFF F3, BUF, RECL, 04, 2048, 01 {too many arguments}
This error will be detected by the macro processor during the one-to-one mapping of actual arguments and parameters
c) RDBUFF F3, , RECL, 04 {no value specified for &BUFADR}
This error will be detected by the assembler during the assembly of line 40
75 STCH ,X {&BUFADR is null}
d) RDBUFF F3, RECL, BUF {arguments specified in wrong order}
This error will be detected by the macro processor during the one-to-one mapping of actual arguments and parameters