Part L: Assembly Language, part 3 (24 marks)
For this question, three text files called q12a.asm, q12b.asm and q12c.asm have been provided for you to fill in your answers. You must provide code that completes each of the functions below:
a) Inq12a.asm,countthenumberof1digitsinthebinarynumberstoredin$a0and store that count value in $v0. For example, if the contents of $a0 are 0xFFFFFFFF, $v0 would be set to decimal value 32. (8 marks)
b) Inq12b.asm,assumethat$a0and$a1containtwopositiveintegers.Calculatethe least common multiple (the smallest positive integer that is evenly divisible by both $a0 and $a1) and store this value in $v0. (8 marks)
Copyright By PowCoder代写 加微信 powcoder
c) In q12c.asm, assume that $a0 is storing a pixel colour value for your bitmap display. Set $v0 to the grayscale version of this pixel by setting the red, green and blue values of $v0 to the average of the red, green and blue values of $a0. For example, if $a0 contains the value 0x002174, $v0 will receive the value 0x313131. (8 marks)
When completing this question, make sure that you do the following:
Comment your code to help us understand each of your steps.
Make sure your code assembles and runs before you submit it!
We will be using testing scripts to check the functionality of your code. Keep the following guidelines in mind before you submit your solution:
Only add your code to the end of the files provided, after the comment that says, “ONLY ALTER THE CODE BELOW THIS LINE”. Anything above this comment will be replaced with our own testing code.
Save and submit your .asm files as plain text (do not save it in Word or a PDF or any other file format that could interfere with our testing scripts).
Do not implement your solutions recursively.
Once your code is complete, do not use jr $ra or syscall commands to terminate
your program. This will cause our testing scripts to fail.
Student Number: __________________ 16 (continued)
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com