SCC150 – MIPS/Assembly Week 14/16 Assessed Practical
SCC – Lancaster University Week 14/16
Copyright By PowCoder代写 加微信 powcoder
Assessed Exercise
• This exercise is assessed
• You should work alone
• The deadline is Friday Week 16, 4pm GMT
• You must submit your work before the deadline
• You should submit
• ASM file containing your code
• Text file (doc, pdf, txt, odt) containing your predicted marks
NOTE: Teams labs spaces are not moderated. Please be careful when sharing information about your code. All submissions are processed by a plagiarism checking tool and code similarities can get you in trouble.
Be careful
• Do not share code or code solution in teams chat or the forum. • If you need help, talk to one of the TAs one-to-one.
• All code submissions are checked by plagiarism checking tools.
• If you have any questions about coursework please ask academics. • Do not trust information that you read on group chat.
• Exploit lab time to discuss any problem with Tas and academics.
• If you are not sure, ask us.
• If you are facing any difficulties and you cannot meet deadlines, please contact out teaching office as soon as possible.
• Teaching academics cannot grant extensions.
Coursework context
• Build a 2d drawing application using MARS. • Support a simple cli interface.
• Supported operations:
• cls: paint all pixels to a specific colour
• Draw row: paint white all pixels of a horizontal line. • Draw column: paint white all pixels of a vertical line. • Draw a triangle in a different colour
• Your solution should follow the coursework requirement to get full marks (e.g. use procedure where asked, follow procedure rules).
• Using syscall to print to screen • Using syscall to read an integer • Interpret instruction
• Drawing on screen
• Implementing procedure • Triangles
• Mark yourself
Syscall – Printing a String
#using .data to store the string you want to print
#.asciiz tells it that it has an ascii string and that it ends with a zero #info is just a label
info: .asciiz “This string has instructions”
#back to main program here (.text)
addi $v0,$zero,4 la $a0, info
#tell syscall to print string (put code 4 into $v0) #load the string address (label info) into $a0 #$a0 is the parameter for syscall
#call syscall – it will only print now
Syscall – Reading an Integer
• To read an integer, you must put code 5 into syscall ($v0)
• When you call syscall, you can type the integer in using the bottom window
• The result is stored in $v0 here
Interpret Instruction
• You’ve told the user what to do
• You’ve read the integer
• Decide what to do with the instruction • There are two types of instruction:
• Select task
1. cls (colour background) 2. Row
4. Triangles (A only)
• Select colour – there should be several choices of colour
Drawing on screen
• You must be able to carry out the instruction
• Week 12’s practical instructions will help with this if you’ve forgotten
• Use heap for display now because print string will use the data section • CLS
• Fill in the background of the screen in the correct colour • Row
• Draw a horizontal line (in the correct colour) • Column
• Draw a vertical line (in the correct colour) • Triangle
• Draw a filled triangle starting at a peak of given coordinates (in the correct colour) • Exit
CLS – Example (in blue)
lui $s0,0x1004
addi $t8,$zero,0x00ff addi $t0,$s0,0
lui $s1,0x100C
drawPixel:
sw $t8,0($t0)
addi $t0,$t0,4
bne $t0,$s1,drawPixel
#bitmap display base address in $s0 (heap) #set colour to blue in $t8
#initialise $t0 to base address, will count #end of screen area in $s1
#store colour $t8 in current target address #increment $t0 by one word
#if haven’t reached the target yet, repeat
Drawing lines – algorithm
1. Find start point and paint pixel.
2. Add the appropriate number to find the memory location of the next pixel and paint.
3. If we have not reached the end of the line, go to 1.
Example – cls, row
Example – column
Steps for procedure implementation
1. Placeparametersinaplacewheretheprocedurehasaccess.
2. Transfercontroltotheprocedure.
3. Acquirethestorageresources(e.g.variables,arrays)needed for the procedure.
4. Performthedesiredtask.
5. Placetheresultvalueinaplacewherethecallercanaccessit.
6. Returncontroltothepointoforigin.
• To get the triangles working, you need a good understanding of the bitmap memory structure – how to move between rows and columns reliably
• Set start row and column.
• In the first row, draw a single pixel
• Go to the next row, draw extra pixels on either side of the single pixel in the row above (the number of extra pixels is determined by “growth”).
• Length of row = length of previous row + 2*growth
• Don’t worry about the triangle wrapping around
0 000 00000
Example – triangles
Input data:
1 (cls), 3 (yellow)
4 (triangle), 5 (blue), 4 (row), 55 (col), 2 (growth) 4 (triangle), 1 (red), 200 (row), 88 (col), 5 (growth)
• There will be an automated marking system that will test your code
• This will detect: • Procedures
• Use of syscalls
• In week 18, the Senior TAs will mark your work. You MUST attend this
session. The TA will:
• Provide feedback
• Clarify any queries about the automated marking • Ask questions about your code
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com