void drawchar(x, y, char)
draws an ASCII char at the given location, using a bunch of short lines on the graphics device.
You need only handle the following chars:
digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
punctuation: PERIOD, MINUS, PLUS
letters: E
void draw_string(x, y, char*)
draws the given string, char by char, until '\0', starting at the given (x,y) position on the screen.int int_to_ascii(int, bool, char*)
converts integer to sequence of ascii chars, base 10, null terminated, in the given buffer. Considers the int signed if the bool arg is true, otherwise as unsigned. Returns the number of chars in the resulting string.void draw_int(x, y, int)
draws the chars corresponding to the given int at the given (x,y) position on the screen.
The exponent itself is represented in binary, but it corresponds to a power of ten, ie to movement of the decimal point of the mantissa. The mantissa has an implied decimal point after the first digit, so the number 3.14159 would be stored with an exponent of zero. Numbers should be normalized, ie the first decimal digit of the mantissa must not be zero (unless the number is actually zero, so all the digits are zero, in which case the whole float10 represents the number 0.00000, and the exponent must be zero.)
The largest (in absolute value) possible float10 is +/- 9.99999E63. The smallest non-zero float10, in absolute value, is +/- 1.00000E-64. (In other words, you should not generate denormalized float10s upon underflow. Note the asymmetry in the maximum vs minimum exponent - this is caused by its 2's-complement representation.)
Digression: decimal floating point formats pretty much identical to this one are in fact used on almost all hand calculators, to avoid all the work of conversion between decimal and binary, and to make their operation more understandable to the users. Cheap hand calculators generally have 4-bit processors, sometimes called "microwave oven controllers", and do their arithmetic one decimal digit at a time.
float10 float10_add(float10, float10)Programming idea: you may use a clock-radio-LED style setup, with a predefined set of lines of which each char activates some subset according to a mask in a table. Or you may use some other method. You might also consider using more subroutines than just those required above.
takes two float10's and returns their sum. they might be positive or negative. The exponents might be positive or negative. (Extra credit for correctly handling overflow by terminating the program, with the address of an error message left in r1.)void float10_to_ascii(float10, char *)
converts a float10 to a string of ascii chars, as in 3.14159E2 for the number 314.159, represented with the sign bit 0 (for positive), the mantissa 0x314159, and the exponent 2. Don't forget that the exponent might be negative.void draw_float10(x, y, float10)
draws the characters corresponding to the given float10 at the given (x,y) position on the screen.
You should put each above subroutine in its own file, named after the contained subroutine, ie drawchar.s, draw_string.s, int_to_ascii.s. Link them together with a Makefile. Create a bunch of "main" routines (files containing start:) and you can link each one to the rest of the stuff to run that particular test. Call the testing files test1.s, test2.s, etc. And please document your code, especially the tests.
We will give partial credit for simple clear correct C code implementing the required functions, which you should write anyway as a step towards writing the assembly code.
Due midnight Wed April 3. To hand in your code and other files, log into a *.cs.unm.edu linux machine and run
~bap/public_html/bin/hw-handin dirs-and-files
Hand in checklist: