shift.s 692 Bytes
Newer Older
Benoit Perrot's avatar
Benoit Perrot committed
1
2
3
### runtime library
	.text
exit:
4
	li	$a0, 0
Benoit Perrot's avatar
Benoit Perrot committed
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
	li	$v0, 10
	syscall
print:
	li	$v0, 4
	syscall
	jr	$ra
print_int:
	li	$v0, 1
	syscall
	jr	$ra

	.data
eol:
	.asciiz "\n"

## test instructions:	sllv, sll, sra, srav, srl, srlv
	.text
main:
	li	$t0, -2048
	li	$t1, 2
	li	$t2, 21

	sllv	$a0, $t0, $t1
	jal	print_int
	la	$a0, eol
	jal	print
	
	sll	$a0, $t0, 1
	jal	print_int
	la	$a0, eol
	jal	print
		
	move	$a0, $t0
	jal	print_int
	la	$a0, eol
	jal	print

	sra	$a0, $t0, 1
	jal	print_int
	la	$a0, eol
	jal	print

	srav	$a0, $t0, $t1
	jal	print_int
	la	$a0, eol
	jal	print

	srlv	$a0, $t0, $t2
	jal	print_int
	la	$a0, eol
	jal	print
	
	srl	$a0, $t0, 20
	jal	print_int
	la	$a0, eol
	jal	print

	j	exit