aboutsummaryrefslogtreecommitdiff
path: root/semestre 3/architecture des ordinateurs/tme/tme5/exo2.asm
blob: 00354a71a31aa65bc1e1a93f2ccb7415aea285b1 (plain)
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
.data
a: .word 0 # 0x1001 0000
b: .word 0 # 0x1001 0004
.text
	lui $8, 0x1001 # $8 <- 0x1001 0000
	ori $2, $0, 5
	syscall
	lui $8, 0x1001 # $8 <- 0x1001 0000
	sw $2, 0($8)
	ori $2, $0, 5
	syscall
	lui $8, 0x1001 # $8 <- 0x1001 0000
	sw $2, 4($8)
	
	lw $9, 0($8) # tmpa
	lw $10, 4($8) # tmpb
while:
	beq $9, $10, end_while
	# tmpb < tmpa -> else
	slt $11, $10, $9
	beq $11, $0, else
	subu $9, $9, $10
	j end_if
else:
	subu $10, $10, $9
end_if:
	j while
end_while:
	ori $2, $0, 1
	or $4, $0, $9
	syscall
	ori $2, $0, 10
	syscall