

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for assignment 2 of ece 2030: introduction to computer engineering, focusing on differential pulse code modulation (dpcm) image compression. Students are required to write an assembly program to perform dpcm compression on a 4x4 array both horizontally and vertically. The concept of dpcm and its benefits in image compression. Part i of the assignment involves writing the program, and part ii requires encapsulating image printing as procedures.
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Purpose: To learn how to implement iterative programming constructs at the assembly language level, utilize branches and re-emphasize the 1-dimensional nature of memory.
Assignment: Your assignment involves the processing of an array. A graphic image (such as a photograph) is usually stored in a computer as an array of integers. For a black-and-white image, 0 represents black, 255 represents white, and the numbers in between are shades of gray. Since graphic files tend to be large, graphics compression is a common task for a computer. One common step in image compression is called Differential Pulse Code Modulation (DPCM). Compression tends to work best with smaller numbers than with larger ones, and DPCM tries to change some of the large numbers in the array into small ones without losing information. That way, you can restore the image to its original value when you want to look at it. Here’s how it works: instead of storing the value of each element in the array, store the difference between each element and the one just to its left. Here’s an example.
Original Image Second Image [146 147 208 210] [146 1 61 2] [148 130 200 202] Ë DPCM Ë [148 -18 70 2] [148 148 197 295] [148 0 49 98] [140 143 203 210] [140 3 60 7]
Here’s how we got the values in the first row: 146 (no change) 147 – 146 = 1 208 – 147 = 61 210 – 208 = 2
Overall, the numbers in the array are smaller then before and so hopefully they would compress better. Notice that the first element in each row is always the same as in the original and notice that negative numbers are possible.
Unfortunately, since there is nothing to the left of the elements in the leftmost column, those numbers are still just as large as before. We can fix that by doing a DPCM again, this time vertically. Each element in the result array will now be the difference between that element and the element above it in the array. Here’s an example using the previous result image:
Second image Final Image [146 1 61 2] [146 1 61 2] [148 -18 70 2] Ë DPCM Ë [ 2 -19 9 0] [148 0 49 98] [ 0 18 -21 96] [140 3 60 7] [ -8 3 11 -91]
Here’s how we got the values in the first column: 146 (no change again) 148 – 146 = 2 148 – 148 = 0 140 – 148 = -
That got rid of the large values in the first row. Note that this time the first value in each column is unchanged instead of the first value in each row as before.
Part I: Your assignment is to write a program in assembly to perform DPCM on an array twice, first horizontally and then vertically. You’ll need to use loops to navigate around the array. For example, to do the horizontal DPCM, you’ll want to start at the first element in the first row, do the subtraction and store the result, repeat that for each element in that row, and then start over and repeat for the second row. You should print out the original image, the second image, and the final image (remember to put spaces between the numbers in the arrays!). You need a second image to store the results of the row difference. The final image is computed by computing column differences over the second image.
The arrays we use will be 4x4 elements. Here’s some data declarations to help you get started:
#################################################################### .data strA: .asciiz “Original Array:\n “ strB: .asciiz “Second Array:\n: “ strC: .asciiz “Final Array:\n “ newline: .asciiz “\n” space : .asciiz “ “
Original: .word 200, 270, 250, 100 .word 205, 230, 105, 235 .word 190, 95, 90, 205 .word 80, 205, 110, 215
Second: .space 64 Final: .space 64
.align 2
.globl main .text
main: # Your fully commented program starts here.
Part II:
Modify the preceding program such that the blocks of code to print the images to the console are encapsulated as procedures. Thus your main program will call a procedure to print an image to the screen. Depending on the arguments that are passed to the code the original or modified image will be printed. Determine by looking at the text segment how much shorter the program has become by using procedures.
Grading Guidelines: