nayaka
May 3rd, 2006, 03:14 PM
Hi do anybody know how to write a add macro wi th following :
# The prototype statement for ADD should be:
&NAME ADD &NUMS,&TYPES,&SUM,&R=1,&WKR=0
Of course, you may choose your own variable symbols in place of &NAME and the positional operands, but the keywords given here (R= and WKR=) are expected.
# &NUMS is a sublist of implicit addresses of the numbers to be added, and they may be a mix of types F, H, and P. For example:
F1 DC F'1'
HM500 DC H'-500'
P3923 DC P'3923'
...
PSUM DS PL3
and the instruction to get the sum of these and store it in location PSUM might be:
ADD (F1,HM500,P3923),(F,H,P),PSUM
# &SUM is the (optional) implicit address of the location to receive the value of the sum, and may be type F, H, or P.
# &R is the register to use for the calculations and should be other than the register specified as &WKR (which should be used for the CVB and CVD instructions if any decimal summands were specified).
# Your macro should produce an error MNOTE (code 8) if either the &NUMS or &TYPES operand is missing (check this using the count attribute, K'), or if they have an unequal number of elements (check this using the number atribute, N'). Your macro should produce a warning MNOTE (code 4) for each of the &NUMS or &SUM which is a type other than F, H, or P (include the label of the bad variable in the MNOTE).
# Each element of the &NUMS sublist (paired with its corresponding element of the &TYPES sublist) should be processed in turn in a conditional assembly loop. The first time a binary (F or H) valued summand is encountered, a L or LH instruction should be generated to copy the value to &R; thereafter, an A or AH instruction should be generated to add the summand to the binary sum in &R. In both cases, the mnemonic (L or LH, A or AH) should contain an LCLC symbol such as &H whose value is null or 'H' depending on whether the variable in question is type F or type H. Then the mnemonic would, for example, be written L&H which will generate L or LH as appropriate.
# The first time a decimal valued summand is encountered, an LCLB flag should be set using SETB, and a ZAP instruction should be generated to initialize and add the summand to a uniquely named (via &SYSNDX) doubleword workarea to be generated within the macro expansion; thereafter, any decimal summands should be added to the doubleword using AP.
# After all the summands have been processed, if there were any decimal (type P) summands (see the LCLB flag above), instructions should be generated to convert their sum in the doubleword to a binary value (use register &WKR) and add it to the sum of the binary summands in register &R.
# If the result (third positional operand) has been specified and is type F or H (determine this by referring to its type attribute, T'), a ST or STH instruction should be generated to save the result (code the mnemonic as ST&H as above). If the type is P, generate instructions to convert the result in &R to decimal in the doubleword, then ZAP it to the result location. Also, set the LCLB flag.
# Finally, if there were any decimal summands (the LCLB flag above was set), or if &SUM is decimal, the macro should generate a uniquely named doubleword, as well as a branch instruction to get around it.
# Your assembly step should end with a condition code no greater than 8, and this will allow execution of the program to proceed. The program has two XDUMP instructions, the last of which will display the contents of storage areaas which have been altered during execution. You should verify your results by inspecting these areas.
# The prototype statement for ADD should be:
&NAME ADD &NUMS,&TYPES,&SUM,&R=1,&WKR=0
Of course, you may choose your own variable symbols in place of &NAME and the positional operands, but the keywords given here (R= and WKR=) are expected.
# &NUMS is a sublist of implicit addresses of the numbers to be added, and they may be a mix of types F, H, and P. For example:
F1 DC F'1'
HM500 DC H'-500'
P3923 DC P'3923'
...
PSUM DS PL3
and the instruction to get the sum of these and store it in location PSUM might be:
ADD (F1,HM500,P3923),(F,H,P),PSUM
# &SUM is the (optional) implicit address of the location to receive the value of the sum, and may be type F, H, or P.
# &R is the register to use for the calculations and should be other than the register specified as &WKR (which should be used for the CVB and CVD instructions if any decimal summands were specified).
# Your macro should produce an error MNOTE (code 8) if either the &NUMS or &TYPES operand is missing (check this using the count attribute, K'), or if they have an unequal number of elements (check this using the number atribute, N'). Your macro should produce a warning MNOTE (code 4) for each of the &NUMS or &SUM which is a type other than F, H, or P (include the label of the bad variable in the MNOTE).
# Each element of the &NUMS sublist (paired with its corresponding element of the &TYPES sublist) should be processed in turn in a conditional assembly loop. The first time a binary (F or H) valued summand is encountered, a L or LH instruction should be generated to copy the value to &R; thereafter, an A or AH instruction should be generated to add the summand to the binary sum in &R. In both cases, the mnemonic (L or LH, A or AH) should contain an LCLC symbol such as &H whose value is null or 'H' depending on whether the variable in question is type F or type H. Then the mnemonic would, for example, be written L&H which will generate L or LH as appropriate.
# The first time a decimal valued summand is encountered, an LCLB flag should be set using SETB, and a ZAP instruction should be generated to initialize and add the summand to a uniquely named (via &SYSNDX) doubleword workarea to be generated within the macro expansion; thereafter, any decimal summands should be added to the doubleword using AP.
# After all the summands have been processed, if there were any decimal (type P) summands (see the LCLB flag above), instructions should be generated to convert their sum in the doubleword to a binary value (use register &WKR) and add it to the sum of the binary summands in register &R.
# If the result (third positional operand) has been specified and is type F or H (determine this by referring to its type attribute, T'), a ST or STH instruction should be generated to save the result (code the mnemonic as ST&H as above). If the type is P, generate instructions to convert the result in &R to decimal in the doubleword, then ZAP it to the result location. Also, set the LCLB flag.
# Finally, if there were any decimal summands (the LCLB flag above was set), or if &SUM is decimal, the macro should generate a uniquely named doubleword, as well as a branch instruction to get around it.
# Your assembly step should end with a condition code no greater than 8, and this will allow execution of the program to proceed. The program has two XDUMP instructions, the last of which will display the contents of storage areaas which have been altered during execution. You should verify your results by inspecting these areas.