IUP Computer Science
CO 300 Spring 1999

Project #6
(Due by 5 pm 3 May 1999)

You are to write an assembly language macro library named MACS.MLB which works in such a way to make the program in PROJECT:P6MAIN.MAR function correctly when combined with the macros defined in your library. Your library needs to consist of at least 7 macros as described below and the two of the macros, SHOWC and SHOWI, that you were given long ago. The two "show" macros are given to you in a file called MACS.MAR in the PROJECT directory. Your macros must be capable of being used without interfering with any of the instructions that surround them in a program.

CALL Macro

This macro must accept up to 11 arguments: the first is the name of a procedure to call; the rest are arguments for the procedure. Your macro should generate a CALLG instruction with appropriate operands and an argument list that the CALLG can use. The argument list must be generated in such a way that it does not get in the way. As an example, CALL XYZ THIS, THAT, OTHER should produce something like the following (or its equivalent).

               brb          doit
     list:     long         3
               .address     this
               .address     that
               .address     other
     doit:     callg        list, xyz
The user of this macro must not be required to declare any data.

GETDAY Macro

This macro accepts one argument: a reference to an 11-byte storage area. Your macro must get the current date from the computer system and store it in the 11-byte area. The form of the date must be dd-mmm-yyyy (such as 16-APR-1999). You will need to use at least one system service in this macro. The user of this macro must not be required to declare any data area other than the 11- byte area. Ex. GETDAY TODAY

READNMAKE Macro

This macro accepts two arguments: a length (the maximum number of characters to read) in any valid operand form and a reference to an 8-byte storage area. Your macro must read "length" characters from the keyboard (length may be assumed to be <= 80), create a fixed- length string descriptor and store the descriptor in the 8-byte area. The user of this macro must not be required to declare any data area other than the empty 8-byte descriptor storage. Ex. READNMAKE #30, namedesc

COUT Macro

This macro accepts one or two arguments: if there are two arguments, the first is a reference to an array of characters and the second is the length (number of characters in the array); if there is only one argument, it is a fixed-length string descriptor. Your macro must display starting at the current cursor location the characters of the array or that the descriptor refers to. Here are two examples with an idea of what to generate.

     x:  .ascid     /Trash/        ; The data here
     y:  .ascii     /Garbage/      ; Use of macro and what it generates

Macro Use:       cout    x             cout    y, #7

What the macro   movl    x+4, r0       showc   y, #7  or  movab  y, r0
generates:       cvtwl   x,r1                             movl   #7, r1
                 jsb     writestr                         jsb    writestr
CENTER Macro

This macro accepts the same arguments as the COUT macro. Your macro must display the characters of the array or that the descriptor refers to centered on the line where the cursor is (leaving the cursor after the last character).

LEFT Macro

This macro accepts the same arguments as the COUT macro. Your macro must move the cursor to the beginning of the line it is currently on and display the characters of the array or that the descriptor refers to (leaving the cursor after the last character).

RIGHT Macro

The macro accepts the same arguments as the COUT macro. Your macro must display the characters of the array or that the descriptor refers to so that the last character of these is in column 80. The cursor should be left at the end of the line.

Hand in a printout of the MACS.MAR file and a assembler listing for the program in P6MAIN.MAR. Then, copy the executable version of P6MAIN to the HANDIN directory and name it after yourself, as in COPY P6MAIN.EXE HANDIN:JLWOLFE.EXE

EXTRA CREDIT: Make the COUT, CENTER, LEFT, and RIGHT macros accept a string constant as an argument (in addition to a descriptor or an array with a length). Such a string constant would have the form <"string"> with both the angle brackets and the double quotes required. When the argument for any of these macros is a string constant, the user of the macro must not be required to declare any data area for it - the macro must handle this. Here is an example and what it might generate:

Macro Use:                    cout <"some text">

What it generates:            brb       s
                         m:   .ascii    "some text"
                         s:   showc     m, #9