-
Notifications
You must be signed in to change notification settings - Fork 0
/
flipper.asm
53 lines (39 loc) · 1.33 KB
/
flipper.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
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 "flipped.pgm" #used as output
axis: .word 1 # 0=flip around x-axis....1=flip around y-axis
buffer: .space 2048 # buffer for upto 2048 bytes
newbuff: .space 2048
#any extra data you specify MUST be after this line
.text
.globl main
main:
la $a0,input #readfile takes $a0 as input
jal readfile
la $a0,buffer #$a0 will specify the "2D array" we will be flipping
la $a1,newbuff #$a1 will specify the buffer that will hold the flipped array.
la $a2,axis #either 0 or 1, specifying x or y axis flip accordingly
jal flip
la $a0, output #writefile will take $a0 as file location we wish to write to.
la $a1,newbuff #$a1 takes location of what data we wish to write.
jal writefile
li $v0,10 # exit
syscall
readfile:
#done in Q1
flip:
#Can assume 24 by 7 again for the input.txt file
#Try to understand the math before coding!
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!