Lecture 12
Memory-Mapped I/O (MMIO)
Lecture
Outline
- I/O devices
- Direct memory access (DMA)
- Memory-mapped I/O (MMIO)
- Drivers
- RARS MMIO device emulators
Examples
Workshop
NOTE: The tasks from this workshop may take time. If one workshop is not enough to solve them, you may take some time from the next workshop (if it does not have a lot of practical materials).
-
Study and run the examples from the lecture.
-
Input a floating-point number, round it to one digit to the right of decimal point (e.g.
3.5) and display it in theDigital Sim Labdisplay. Use digit_lab1.s as a starting program. -
Modify the digit_lab2.s program to display keys pressed in the hexadecimal keyword in the digital display (as decimal values, e.g.
F==15). Use the workshop task as a basis. -
Write a program (based on digit_lab2.s) that inputs an integer value
X(with theReadIntsystem call) and then usesDigital Sim Labto enter 32-bit integers (8 hexadecimal digits)Y. It repeats entering integers until the enteredYis equal toX. Then it printsFOUNDand exits. IfYequals0the program must printSTOPPEDand exit. -
Write a program that draws a square with size 64×64 dots in the middle of
Bitmap Display(see theToolsmenu of RARS) with size 128×128 dots. The color and the thickness of lines in dots is specified by the user (use theReadIntsystem call). See bitmap_display.s as an example.
Homework
Solve the following tasks and submit them into Ejudge:
-
FullRainbow
Write a program that fills
RARS Bitmap Displaywith vertical stripes of equal width (+1 pixel), which are painted with the specified colors. The colors are input as decimal numbers one per line until0is met.0means the end of the input and is not considered as a color. The total number of colors isN <= 100.- Parameters of
Bitmap Display: unit size is2×2; display size is512×256. - Formula for the starting position of the
k-th stripe is256 * k / N(integer arithmetic).
Input:
1249394 7864115 5601041 43775 6706551 0Output:

- Parameters of
-
TheCircle
Write a program that draws a circle in
RARS Bitmap Display. To draw a circle means to paint all points with such coordinates that their distance from pointX/Yis less thanR. The program inputs 5 non-negative numbers:X,Y,R, color of the circle, and color of the background.- Parameters of
Bitmap Display: unit size is2×2; display size is512×256. - It is not guaraneed that the circle fits into the display’s address range or is located within this range at all.
Input:
100 60 50 15641122 5575048Output:

- Parameters of
NOTE: Display 256×512 with unit size 2×2 means 32768 ((256 / 2) * (512 / 2)) pixels each having size of 4 bytes.
References
- Input/Output. Chapter 8 in [COA].
- Memory-mapped I/O. Section 9.2 in [DDCA].
- Memory-mapped I/O (Wikipedia).
- Direct memory access (Wikipedia).