-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignment2_18114006.rtf
52 lines (49 loc) · 1.36 KB
/
assignment2_18114006.rtf
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
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 MS Mincho;}}
{\*\generator Riched20 10.0.17763}\viewkind4\uc1
\pard\ri-1016\sa200\sl276\slmult1\tx8946\tx9088\f0\fs40\lang17 Name: Ankit Aharwal\par
Enroll no: 18114006\par
Batch: O1 BTech CSE 2nd year\par
\fs36 Problem: Write a SimpleRisc assembly program to find the Ramanujan number, the smallest number that is a sum of two cubes in two different ways. \par
\fs32 note: r0 will store the ramanujan number\par
mov r0 1\par
\pard\sa200\sl276\slmult1 mov r1 0 \par
mov r2 -1 \par
mov r6 0 \par
\pard\sa200\sl276\slmult1\tx142\tx9514 .loopA \par
\pard\sa200\sl276\slmult1\tab add r0 r0 1 \par
\tab mov r6 0 \par
\tab mov r1 0 \par
\tab mov r2 -1 \par
\tab b.loopB \par
.loopB \par
\tab add r1 r1 1 \par
\tab mov r3 r1 \par
\tab mul r3 r3 r3 \par
\tab mul r3 r3 r1 \par
\tab cmp r3 r0 \par
\tab bgt .loopA \par
\tab mov r2 -1 \par
\tab b .loopC \par
.loopC \par
\tab add r2 r2 1 \par
\tab mov r4 r2 \par
\tab mul r4 r4 r4 \par
\tab mul r4 r4 r2 \par
\tab add r5 r3 r4 \par
\tab cmp r5 r0 \par
\tab bgt .loopB \par
\tab beq .increaseCounter \par
\tab cmp r2 r1 \par
\tab beq .loopB \par
\tab b .loopC \par
.increaseCounter \par
\tab add r6 r6 1 \par
\tab cmp r6 2 \par
\tab bgt .exit \par
\tab beq .exit \par
\tab b .loopB \par
.exit \par
\fs22\par
\par
}