-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdec2bin.s
More file actions
61 lines (45 loc) · 1.38 KB
/
dec2bin.s
File metadata and controls
61 lines (45 loc) · 1.38 KB
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
.text
.globl dec2bin
.include "macros/syscalls.s"
.include "macros/stack.s"
.include "macros/subroutine.s"
li $a0, 1234
li $a1, '.'
li $a2, 1234567
li $a3, 7
jal dec2bin
exit()
# output should be
# 10011010010.00011111100110101101101
dec2bin: # void dec2bin( whole, radix, fractional, precision )
# a0: whole
# a1: radix
# a2: fractional
# a3: precision
# v0: 0
# t0: whole
# t1: radix
# t2: fractional
# t3: precision
# t4: mantissa_size
# Demarshal your input arguments
move $t0, $a0
move $t1, $a1
move $t2, $a2
move $t3, $a3
li $t4, 23 # final int mantissa_size = 23;
marshal_args($t0)
save_state()
jal whole2bin # whole2bin( whole );
restore_state()
demarshal_results()
print_c($t1) # mips.print_c( radix );
marshal_args($t2, $t3, $t4)
save_state()
jal fractional2bin # fractional2bin(fractional, precision, mantissa_size);
restore_state()
demarshal_results()
print_ci('\n') # mips.print_c('\n');
# Marshal your output arguments
li $v0, 0
jr $ra