0% found this document useful (0 votes)
6 views

SP HW5 Spring2024

system programming HW

Uploaded by

sara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

SP HW5 Spring2024

system programming HW

Uploaded by

sara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PALESTINE POLYTECHNIC UNIVERSITY

COLLEGE OF INFORMATION TECHNOLOGY AND COMPUTER ENGINEERING


SYSTEMS PROGRAMMING - SPRING2024
HOMEWORK #5
INSTRUCTOR: ENG. YOUSEF A. SALAH

Q1) Given the following macro definition:

RMCR MACRO &BASE, &TIMES


IF (&TIMES EQ 0)
LDA #1
ELSEIF (&TIMES EQ 1)
+LDA &TIMES
ELSE
+LDA &BASE
ENDIF
RMO A, T
&PW SET &TIMES
WHILE (&PW GE 1)
MULR T, A
&PW SET &PW - 1
ENDW
MEND

Answer the followings:


(a) How would this macro expanded for each of the following calls:
1) RMCR NUM, 2
2) RMCR INP, 1
(b) For the following invocation: RMCR N, 5
1) How will the macro be expanded?
2) What are the contents of DEFTAB, NAMTAB, and ARGTAB?
(c) What is the function of this macro?

Q2)
Q3)

Q4) What are the differences between positional parameters and keyword parameters?

Q5) In reference to the Macro processor discussed in the textbook (Pages 184-185), Indicate
whether each of the following statements is TRUE or FALSE:
a) The LEVEL variable in the DEFINE procedure is used to keep track with the
beginning and end of each nested macro definition.
b) The Macro processor allows calling a macro inside a macro definition.
c) The Macro processor allows defining a macro inside another macro.
d) When the EXPANDING variable is TRUE the macro processor reads lines from the
source code.
e) Comments are stored in the DEFTAB during macro definition.
f) The logic of this macro processor is used to handle keyword parameters.

Q6) (a) When is it preferable to write a macro instead of a function?


(b) Write a C++ macro that has three parameters A, B and C. The macro will return the
minimum value stored in its parameters.

You might also like