COP3402, Fall 2000, Assignment 5
Due Thursday, December 7 at the start of class
Restrictions for this assignment
-
Create and use the macros I describe. Do not create any other macros.
Use procedures that pass parameters on the stack.
-
All procedures must be less than 35 lines. You may exclude the inital
pushes and the final pops from this count.
-
All procedures must pass parameters on the stack. Functions may still use
AX to return a value.
-
You may only reference global variables by name in main. You may reference
constant data, like messages to be displayed, by name anywhere in the program.
-
Use procedures appropriately.
Macros to create
-
A macro that will push a sequence of registers. Any number of registers can
be pushed. (use IRP)
pushReg <ax,bx,cx>
-
A macro that will pop a sequence of registers. Any number of registers can
be popped. (use IRP)
popReg <cx,bx,ax>
-
A macro that will call a procedure and push the procedures parameters on
the stack.
-
Either write it so that it can accept up to four parameters (using IFNB)
do_call calcTotal,arrayLength,<offset array>,,
-
Or write it so that it can accept any number of parameters (using IRP)
do_call calcTotal,<arrayLength,<offset array>>
-
A macro that will define an area of memory and fill it with consecutive values.
It will have three parameters: count, define, and start
-
count: how many elements to create
-
define: the size of each element. It will be passed as either db or dw
-
start: the value to assign to the first element. Each element will have a
value one larger than the previous. For example, if the call were
fill 10,db,0
then 10 bytes would be allocated with the values 0,1,2,3,4,5,6,7,8,9
-
A macro that will initialize variables.
-
Either write it so that it can accept up to four variables and values (using
IFNB)
init <ax,0>,<num,1>,,
-
Or write it so that it can accept any number of parameters (using IRP)
init <<ax,0>,<num,1>>
Create a program that will convert an unisgned number in one base to
an unsigned number in another base. The user will be able to perform many
such translations. When the use enters a base of 0, then exit the main loop.
-
Clear the screen when the program starts and move the cursor to 0,0.
-
Read the first base from the user. It will be a number in base 10. If the
number is 0, then exit the main loop. You must validate this number:
-
It can be 0, or it must be in the range from 2 to 36, inclusive. If it is
out of range, then print an appropriate error message.Also, ignore the entire
string, and prompt the user for a new base.
-
All the digits must be valid for base 10. If there is a bad digit then print
an appropriate error message. Also, ignore the entire string, and prompt
the user for a new base.
-
The number cannot create an overflow. If there is an overflow, then print
an appropriate error message. Also, ignore the entire string, and prompt
the user for a new base.
-
Read the second base from the user. It will be a number in base 10. If the
number is 0, then exit the main loop. You must validate this number:
-
It can be 0, or it must be in the range from 2 to 36, inclusive. If it is
out of range, then print an appropriate error message.Also, ignore the entire
string, and prompt the user for a new base.
-
All the digits must be valid for base 10. If there is a bad digit then print
an appropriate error message. Also, ignore the entire string, and prompt
the user for a new base.
-
The number cannot create an overflow. If there is an overflow, then print
an appropriate error message. Also, ignore the entire string, and prompt
the user for a new base.
-
Read a number from the user. This number will be in the first base. If the
number is 0, then exit the main loop. You must validate this number:
-
All the digits must be valid for the first base. If there is a bad digit
then print an appropriate error message. Also, ignore the entire string,
and prompt the user for a new number.
-
The number cannot create an overflow. If there is an overflow, then print
an appropriate error message. Also, ignore the entire string, and prompt
the user for a new number.
-
Translate and display the number in the second base.