Question: Task 2 : Paint a number ( 1 0 marks ) The template for this task contains data for bitmaps of the digits 0 -

Task 2: Paint a number (10 marks) The template for this task contains data for bitmaps of the digits 0-9, stored at the label DigitPixels. Each digit consists of 3x5 pixels of data. The first 3 words are the first row of pixels, the next 3 words are the second row, and so on. For example, the digit 2 is represented as 00000000 FFFF FFFF FFFF 0000 FFFF 0000 FFFF 0000 FFFF FFFF 000000000000 You can see the pattern here, the zeros paint the shape of the character 2 in black, with the background in white (FFFF). Your task is to write a subroutine called SubDrawDigit that paints a digit into the graphics memory. The beginning of the subroutine should be structured as follows: DigitDataAddress, HEX 0 DigitDisplayAddress, HEX 0 SubDrawDigit, HEX 0 In the DigitDataAddress argument, you will pass the address of the first pixel data for the digit you want to paint, as defined in the DigitPixels. In the DigitDisplayAddress argument, you will provide the address of the top-left corner in the graphic memory where you wish to start painting the digit. For example, to paint the digit 0, starting from the second pixel in the second row, we could use the following code: Load DigitPixelsAddr Store DigitDataAddress Load Display11 Store DigitDisplayAddress JnS SubDrawDigit Halt Display11, HEX 0F11 Note that the address 0F11(label Display11) lies exactly 17 words after the start of the graphics memory. This means were skipping the first row (16 words) and the first pixel in the second row (1 word). Here we simply use DigitPixelsAddr to refer to the first character (for the digit 0). For the other characters, we would have to add a corresponding offset into the DigitPixels memory.
To paint a digit in your subroutine, you can follow this recipe: Each digit consists of 15 pixels (3 columns x 5 rows). You need to loop through these 15 pixels, loading each one from the DigitPixels definition and storing it in the graphics memory. Your subroutine should contain two nested loops: o Outer Loop (Rows): Loop through each row of the digit. o Inner Loop (Columns): Within the outer loop, loop through each column of the current row. - Retrieve the corresponding pixel data from DigitDataAddress - Store the pixel data at the correct graphics memory address (e.g. DigitDisplayAddress plus the current row offset and current column offset). Once you have copied all 15 pixels from the DigitPixels definition into the graphics memory, you can exit the subroutine. Your subroutine must include sufficient comments to help others (such as the person marking your assignment) in understanding the purpose of your code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!