-
Notifications
You must be signed in to change notification settings - Fork 0
/
bai2.asm
60 lines (46 loc) · 842 Bytes
/
bai2.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
60
.data
str: .asciiz "Nhap ban kinh duong tron: "
PI: .float 3.1415
str1: .asciiz "Dien tich = "
str2: .asciiz "Chu vi = "
fail: .asciiz "Phai nhap R >= 0"
.text
la,$a0,str
li,$v0,4
syscall
l.s $f1,PI ## $f1 = PI = 3.1415
mfc1 $zero,$f5 ## $f5 = 0
la,$v0,6 ## $f0 -> R
syscall
c.lt.s $f0,$f5
bc1t FAIL
add.s $f3,$f1,$f1 ## f3 = 2pi
mul.s $f3,$f3,$f0 ## Chu vi = 2pi*R = $f3
mul.s $f4,$f0,$f0
mul.s $f4,$f4,$f1 ## Dien tich = pi*R^2 = $f4
## IN KET QUA
mfc1 $zero,$f5
la,$a0,str2
li,$v0,4
syscall
li,$v0,2
add.s $f12,$f5,$f3
syscall
##
li $v0,11
add $a0,$zero,0xA
syscall
##
la,$a0,str1
li,$v0,4
syscall
li,$v0,2
add.s $f12,$f5,$f4
syscall
li,$v0,10
syscall
FAIL: la,$a0,fail
li,$v0,4
syscall
li,$v0,10
syscall