-
Notifications
You must be signed in to change notification settings - Fork 0
/
border.asm
59 lines (43 loc) · 1.34 KB
/
border.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
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 "borded.pgm" #used as output
borderwidth: .word 2 #specifies border width
buffer: .space 2048 # buffer for upto 2048 bytes
newbuff: .space 2048
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
la $a0,buffer #$a1 will specify the "2D array" we will be flipping
la $a1,newbuff #$a2 will specify the buffer that will hold the flipped array.
la $a2,borderwidth
jal bord
la $a0, output #writefile will take $a0 as file location
la $a1,newbuff #$a1 takes location of what we wish to write.
jal writefile
li $v0,10 # exit
syscall
readfile:
#done in Q1
bord:
#a0=buffer
#a1=newbuff
#a2=borderwidth
#Can assume 24 by 7 as input
#Try to understand the math before coding!
#EXAMPLE: if borderwidth=2, 24 by 7 becomes 28 by 11.
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!