Lab 10
Lab 10
Lab week 10
Name: Le Nho Bach
Student ID: 103487884
Question 4:
To call drawpixel, we need parameters r0 - r3:
● r0 is the screen address
● r1 and r2 are x position and y position respectively
● r3 is the color of the pixel
Question 5:
The loop lineloop, which controls the calling of drawpixel, is used to draw a line:
For details, r4 and r5 are the x and y position of the pixel, respectively. r0 is the
screen address and r3 is the color. In this loop, r0, r5, and r3 are unchanged. r4 is
incremented after a loop because we need to draw a pixel in a line at y position r5.
After drawing a pixel in position (r4, r5), we keep drawing a pixel in position (r4+1,
r5), until r4 is bigger than r8 - the x limit of the screen.
Question 6:
org $8000
mov sp,$1000
and r0,$3FFFFFFF ; Convert Mail Box Frame Buffer Pointer From BUS Address To
Physical Address ($CXXXXXXX -> $3XXXXXXX)
str r0,[FB_POINTER] ; Store Frame Buffer Pointer Physical Address
mov r7,r0 ;back-up a copy of the screen address + channel number
; Draw Box has top left = (10, 10) and bottom right = (18, 26)
draw_horizontal_line:
push {r0-r3}
mov r0,r7 ;screen address
mov r1,r4 ;x
mov r2,r5 ;y
mov r3,r6 ;colour
bl drawpixel
pop {r0-r3}
draw_vertical_line:
push {r0-r3}
mov r0,r7 ;screen address
mov r1,r4 ;x
mov r2,r5 ;y
mov r3,r6 ;colour
bl drawpixel
pop {r0-r3}
draw_vertical_line2:
push {r0-r3}
mov r0,r7 ;screen address
mov r1,r4 ;x
mov r2,r5 ;y
mov r3,r6 ;colour
bl drawpixel
pop {r0-r3}
draw_horizontal_line2:
push {r0-r3}
mov r0,r7 ;screen address
mov r1,r4 ;x
mov r2,r5 ;y
mov r3,r6 ;colour
bl drawpixel
pop {r0-r3}
draw_vertical_line3:
push {r0-r3}
mov r0,r7 ;screen address
mov r1,r4 ;x
mov r2,r5 ;y
mov r3,r6 ;colour
bl drawpixel
pop {r0-r3}
draw_horizontal_line3:
push {r0-r3}
mov r0,r7 ;screen address
mov r1,r4 ;x
mov r2,r5 ;y
mov r3,r6 ;colour
bl drawpixel
pop {r0-r3}
draw_diagonal_line:
push {r0-r3}
mov r0,r7 ;screen address
mov r1,r4 ;x
mov r2,r5 ;y
mov r3,r6 ;colour
bl drawpixel
pop {r0-r3}
Loop:
b Loop ;wait forever
include "FBinit8.asm"
include "drawpixel.asm"