Write a program that inputs two integers (paper color and ink color) and draws an oval on Mars «Bitmap Display» with following settings (note 4X4 pixel size:
To draw an oval you should scale a circle to fit screen rectangle. Look at the example code. After drawing an oval, the program prints all videomemory out in hexadecimal.
3377169 16763989
0x00338811 0x00338811 0x00338811 ... 0x00ffcc55 0x00ffcc55 0x00ffcc55 ... 0x00338811 0x00338811 0x00338811
Example code:
1 .eqv WIDTH 128
2 .eqv HEIGHT 64
3 # Variables
4 .data 0x10008000
5 X0: .float -1
6 X1: .float 1
7 Y0: .float -1
8 Y1: .float 1
9 W: .float 127
10 H: .float 63
11 ZERO: .float 0
12 ONE: .float 1
13 # program fragment
14 .text
15 # ... (come code)
16 l.s $f12 ONE
17 li $s0 0
18 lines: li $s1 0
19 dots: iscale ZERO H Y0 Y1 $s0 $f8
20 iscale ZERO W X0 X1 $s1 $f10
21 mul.s $f8 $f8 $f8
22 mul.s $f10 $f10 $f10
23 add.s $f8 $f8 $f10
24 c.lt.s $f8 $f12
25 movt $s4 $s2
26 movf $s4 $s3
27 dot $s1 $s0 $s4
28 loop $s1 WIDTH dots
29 loop $s0 HEIGHT lines
30 # ... (some other code)
In this example:
iscale a b A B x X is macro that converts integer x in range from a to b to range from A to B, and stores it to float register X
loop reg counter label is macro that organizes a loop of counter steps
X1 and Y1 are 127 and 63, not 128 and 64 because 128-step loop starts from 0 and ends with 127
dot x y color is macros that draws a dot with selected color
All variables are located at 0x10008000, out of standard data address, because videomemory is settled there.
Hint: the settings are equivalent to this (note 1x1 pixel size):
Here is full output for checking: output.txt