Assembly
Language Programming
Program Assignment #3
Write procedures to perform numeric input and output. These
will be designed to be linked to other assembly language
programs. The procedures should not change any
registers unless specified. They should not use any named storage locations -
allocate stack space for local variables if needed. Place the procedure definitions in
NUM.asm. You should test your functions using a separate program of your own. Be
sure to declare the functions as public - see 9.4 for info. Use a small memory
model and near procedure declarations. Do not include a data segment in NUM.asm.
- inNum proc near
- This function reads a number from the keyboard. The input is converted
to a 16-bit unsigned integer. You are given one argument in BL, a number in the range 2 through 16
indicating the radix of the input data. An illegal radix should be
treated as radix 16. Your function must read characters
using a DOS function that does not echo to the screen. Read (and ignore)
characters until a digit (0 through radix-1) is
encountered. This digit is then the start of the input value and should
be echoed to the screen. Continue
to read and echo characters until an illegal character is read (any
non digit for the specified radix). Do not echo this character. Do not
output a CRLF after input is correct. Return the value of
the number input in AX and the last character read in DL.
You are reading unsigned numbers, so detect overflow
appropriately. If overflow occurs during the input
processing, set the CF before returning, otherwise clear
the CF. If overflow occurs, continue processing input normally as
specified above. Note that the digits, A-F, can be upper or lower
case. Only AX and DL may be changed (if you need to
change other registers, you must restore them before
returning)
- outNum proc near
- You are given a single word (on the stack), the unsigned representation
of a value to be displayed. A second argument in BL will specify
the radix (2-16) you should use to display the value. If the radix is
illegal, use 16. No
registers are to be changed by this function. Use
uppercase A-F when displaying the value. Do not add a CRLF to the
output.
Submit a single ZIP file containing your .ASM source file and the assembled
object file. Please name the ZIP file with your last name and the digit 3. For example,
I would submit MARGUSH_3.ZIP. I will assemble and link your
procedures with my own test program. Turn in a printed copy of
your program - it must look nice, so be careful about formatting
it. E-mail the zip archive attached to a mail message. The
subject line of the message must include the words: "Assembly
Language Program 3". Try to make the return address correct
as well! Submit a printed copy.