1 ; See LICENSE file for copyright
and license details.
2 ; azan-nasm is simple muslim prayers calculator.
3 ; print next prayer left duration
or today
's all prayers.
13 offset: dq 0xc142b42c80000000 ;double -2451545
14 to_rad: dq 0x3f91df46a2529d39 ;double pi / 180 to radian
15 to_deg: dq 0x404ca5dc1a63c1f8 ;double 180 / pi to degree
16 g_1: dq 0x3fef8a099930e901 ;double 0.98560027999999999
17 g_2: dq 0x40765876c8b43958 ;double 357.529
18 e_3: dq 0xbe9828c0be769dc1 ;double -3.5999999999999999E-7
19 e_4: dq 0x403770624dd2f1aa ;double 23.439
20 q_5: dq 0x3fef8a6c5512d6f2 ;double 0.98564735999999997
21 q_6: dq 0x4071875810624dd3 ;double 280.459
22 sing_1: dq 0x3FFEA3D70A3D70A4 ;double 1.915
23 sing_2: dq 0x3F947AE147AE147B ;double 0.020
24 RA_1: dq 0x402E000000000000 ;double 15.0
25 asin_1: dq 0x3FF0000000000000 ;double 1
26 eqt_1: dq 0x4076800000000000 ;double 360.0
48 mov rax, SYS_gettimeofday ;sys_gettimeofday(
49 mov rdi, tstamp ;struct timeval *tv,
50 mov rsi, rsi ;struct timezone* tz
53 ; calc_julian:(timestamp / sec_in_day) + jul1970
54 cvtsi2sd xmm0, [tstamp] ;convert timestamp to double
55 divsd xmm0, [sec_inday] ;timestamp / sec_in_day
56 addsd xmm0, [jul1970] ;div result + jul1970
59 ; calc_equation_of_time:
60 addsd xmm0, [offset] ;d = julian - offset
64 movsd xmm1, [g_1] ;g = to_rad * ((d * 0.98560028) + 357.529)
71 movsd xmm3, [e_3] ;e = to_rad * (23.439 - (d * 0.00000036))
77 movsd xmm4, [q_5] ;q = (d * 0.98564736) + 280.459
82 ; sing: ;sing = 1.915 * sin(g);
92 ; sin2g: ;sin2g = 0.020 * sin(2.0*g)
115 ; L: ;L = to_rad(q + sing + sin2g);
116 addsd xmm5, xmm6 ;sing + sin2g
117 addsd xmm5, xmm4 ;+ q
118 mulsd xmm5, xmm2 ;* to_rad
133 ; RA: ;RA = to_deg(atan2(cose * sinL, cosL) / 15.0);
137 fld qword [cose] ;load cose
138 fld qword [cosL] ;load cosL
139 fpatan ;calc atan2 (cose / cosL)
140 fstp qword [RA_2] ;save angle
142 divsd xmm7, [RA_1] ;atan2 result /15.0
143 mulsd xmm7, [to_deg] ;* to_deg
146 ; D: ;D = to_deg(asin(sine * sinL));
147 ; asin = arctan(x / sqrt(1 - x * x))
153 movsd xmm9, xmm8 ; xmm8 = x
154 mulsd xmm9, xmm8 ; xmm9 = x * x
155 movsd xmm10, [asin_1] ; xmm10 = 1
156 subsd xmm10, xmm9 ; 1 - xmm9
157 movsd [asin_1], xmm10 ; asin_1 = (1-x*x)
158 movsd [asin_x], xmm8 ; asin_1 = (1-x*x)
171 ; Eqt ;EqT = q / 15.0 - RA;
172 movsd xmm9, xmm4 ; move q to xmm9
173 divsd xmm9, [RA_1] ; q / 15.0
174 subsd xmm9, xmm7 ; - RA