-
Notifications
You must be signed in to change notification settings - Fork 0
/
cropper.asm
62 lines (50 loc) · 1.48 KB
/
cropper.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
#name:
#studentID:
.data
#Must use accurate file path.
#file paths in MARS are relative to the mars.jar file.
# if you put mars.jar in the same folder as test2.txt and your.asm, input: should work.
input: .asciiz "test1.txt"
output: .asciiz "cropped.pgm" #used as output
buffer: .space 2048 # buffer for upto 2048 bytes
newbuff: .space 2048
x1: .word 1
x2: .word 2
y1: .word 3
y2: .word 4
headerbuff: .space 2048 #stores header
#any extra .data you specify MUST be after this line
.text
.globl main
main: la $a0,input #readfile takes $a0 as input
jal readfile
#load the appropriate values into the appropriate registers/stack positions
#appropriate stack positions outlined in function*
jal crop
la $a0, output #writefile will take $a0 as file location
la $a1,newbuff #$a1 takes location of what we wish to write.
#add what ever else you may need to make this work.
jal writefile
li $v0,10 # exit
syscall
readfile:
#done in Q1
crop:
#a0=x1
#a1=x2
#a2=y1
#a3=y2
#16($sp)=buffer
#20($sp)=newbuffer that will be made
#Remember to store ALL variables to the stack as you normally would,
#before starting the routine.
#Try to understand the math before coding!
#There are more than 4 arguments, so use the stack accordingly.
writefile:
#slightly different from Q1.
#use as many arguments as you would like to get this to work.
#make sure the header matches the new dimensions!