Pi: Difference between revisions
Content added Content deleted
VincentARM (talk | contribs) (Add task to arm assembly raspberry pi) |
VincentARM (talk | contribs) (Add task to aarch64 assembly raspberry pi) |
||
Line 200: | Line 200: | ||
18577 80532 17122 68066 13001 92787 66111 95909 21642 01989 |
18577 80532 17122 68066 13001 92787 66111 95909 21642 01989 |
||
</pre> |
</pre> |
||
=={{header|AArch64 Assembly}}== |
|||
{{works with|as|Raspberry Pi 3B version Buster 64 bits <br> or android 64 bits with application Termux }} |
|||
<syntaxhighlight lang AArch64 Assembly> |
|||
/* ARM assembly AARCH64 Raspberry PI 3B */ |
|||
/* program calculPi64.s */ |
|||
/* for algorithm see a french site : http://www.yann-ollivier.org/pi/pi.php */ |
|||
/************************************/ |
|||
/* Constantes */ |
|||
/************************************/ |
|||
/* for this file see task include a file in language AArch64 assembly*/ |
|||
.include "../includeConstantesARM64.inc" |
|||
.equ NBVAL, 8400 //(2400 decimales) or 16800 (4800 décimales) or 33600 (9600 decimales) |
|||
.equ BASE, 10000 |
|||
//.include "../ficmacros32.inc" // for debugging developper |
|||
/************************************/ |
|||
/* Initialized data */ |
|||
/************************************/ |
|||
.data |
|||
szCarriageReturn: .asciz "\n" |
|||
szMessStart: .asciz "Program 64 bits start.\n" |
|||
szNBZero1: .asciz "0" |
|||
szNBZero2: .asciz "00" |
|||
szNBZero3: .asciz "000" |
|||
.align 2 |
|||
/************************************/ |
|||
/* UnInitialized data */ |
|||
/************************************/ |
|||
.bss |
|||
sZoneConv: .skip 24 |
|||
ibuffer: .skip 4 * (NBVAL+1) |
|||
/************************************/ |
|||
/* code section */ |
|||
/************************************/ |
|||
.text |
|||
.global main |
|||
main: // entry of program |
|||
ldr x0,qAdrszMessStart |
|||
bl affichageMess |
|||
ldr x7,iA |
|||
mov x0,x7 |
|||
mov x1,#5 |
|||
udiv x2,x0,x1 // A / 5 |
|||
mov x1,#0 |
|||
ldr x8,qAdribuffer |
|||
ldr x9,iC // C |
|||
1: // init start array |
|||
str w2,[x8,x1, lsl #2] // store A/5 |
|||
add x1,x1,#1 |
|||
cmp x1,x9 |
|||
blt 1b |
|||
mov x10,#0 // E |
|||
2: // begin loop 1 |
|||
mov x4,#0 // D |
|||
lsl x5,x9,#1 // G |
|||
mov x6,x9 // B |
|||
3: // loop 2 |
|||
ldr w1,[x8,x6, lsl #2] |
|||
mul x1,x7,x1 // |
|||
add x4,x4,x1 // new D |
|||
sub x5,x5,#1 // g = g -1 |
|||
mov x0,x4 // D |
|||
mov x1,x5 // G |
|||
udiv x2,x0,x1 |
|||
msub x3,x1,x2,x0 |
|||
str w3,[x8,x6, lsl #2] // D modulo G |
|||
mov x4,x2 |
|||
sub x5,x5,#1 // G=G-1 |
|||
subs x6,x6,#1 // B=B-1 |
|||
ble 4f // end loop 2 ? |
|||
mul x4,x6,x4 // no compute new D |
|||
b 3b // and loop 2 |
|||
4: |
|||
mov x0,x4 // D |
|||
mov x1,x7 // A |
|||
udiv x2,x0,x1 |
|||
msub x3,x1,x2,x0 |
|||
add x0,x2,x10 // D/A + E |
|||
bl afficherDecimale |
|||
mov x10,x3 // E=D modulo A |
|||
subs x9,x9,#14 |
|||
bgt 2b // end loop 1 ? |
|||
100: // standard end of the program |
|||
mov x0, #0 // return code |
|||
mov x8,EXIT |
|||
svc 0 // perform the system call |
|||
qAdrsZoneConv: .quad sZoneConv |
|||
qAdrszCarriageReturn: .quad szCarriageReturn |
|||
qAdrszMessStart: .quad szMessStart |
|||
qAdribuffer: .quad ibuffer |
|||
iA: .quad BASE |
|||
iC: .quad NBVAL |
|||
/******************************************************************/ |
|||
/* Display decimales */ |
|||
/******************************************************************/ |
|||
/* x0 contains decimale */ |
|||
afficherDecimale: |
|||
stp x4,lr,[sp,-16]! // save registers |
|||
mov x4,x0 |
|||
ldr x1,ival1 |
|||
cmp x0,x1 |
|||
bgt 3f |
|||
cmp x0,#99 |
|||
ble 1f |
|||
ldr x0,qAdrszNBZero1 // display 1 zero |
|||
bl affichageMess |
|||
mov x0,x4 |
|||
b 3f |
|||
1: |
|||
cmp x0,#9 |
|||
ble 2f |
|||
ldr x0,qAdrszNBZero2 // display 2 zeroes |
|||
bl affichageMess |
|||
mov x0,x4 |
|||
b 3f |
|||
2: |
|||
ldr x0,qAdrszNBZero3 // display 3 zeroes |
|||
bl affichageMess |
|||
mov x0,x4 |
|||
3: // conversion and display |
|||
ldr x1,qAdrsZoneConv |
|||
bl conversion10 // decimal conversion |
|||
mov x2,#0 |
|||
strb w2,[x1,x0] |
|||
ldr x0,qAdrsZoneConv |
|||
bl affichageMess |
|||
100: |
|||
ldp x4,lr,[sp],16 // restaur registers |
|||
ret |
|||
ival1: .quad 999 |
|||
qAdrszNBZero1: .quad szNBZero1 |
|||
qAdrszNBZero2: .quad szNBZero2 |
|||
qAdrszNBZero3: .quad szNBZero3 |
|||
/***************************************************/ |
|||
/* ROUTINES INCLUDE */ |
|||
/***************************************************/ |
|||
/* for this file see task include a file in language AArch64 assembly*/ |
|||
.include "../includeARM64.inc" |
|||
</syntaxhighlight> |
|||
{{Out}} |
|||
<pre> |
|||
Program 64 bits start. |
|||
314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009946576407895126946839835259570982582262052248940772671947826848260147699090264013639443745530506820349625245174939965143142980919065925093722169646151570985838741059788595977297549893016175392846813826868386894277415599185592524595395943104997252468084598727364469584865383673622262609912460805124388439045124413654976278079771569143599770012961608944169486855584840635342207222582848864815845602850 |
|||
</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
{{works with|Ada 2005}} |
{{works with|Ada 2005}} |