azan

prayers time calculator written in nasm
git clone git://git.afify.dev/azan
Log | Files | Refs | README | LICENSE

commit d0da0ff404cc7707a87d269af3189bb1cd93bb11
parent 2aa8003831cf2337f3281a39a5d31e08ad00d172
Author: afify <hassan@afify.dev>
Date:   Tue, 24 Nov 2020 18:40:08 +0300

[feat] add option -n print next prayer 24-hour

Diffstat:
Mazan-nasm.s | 36++++++++++++++++++++++++++++++------
Mmacros.s | 14+++++++-------
2 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/azan-nasm.s b/azan-nasm.s @@ -5,6 +5,7 @@ BITS 64 %include "syscalls.s" %include "macros.s" +%include "math.s" %include "config.s" CHECK_OPENBSD @@ -60,6 +61,8 @@ check_argv: mov r12b, [r11+1] cmp r12b, 0x75 ;u je get_timestamp + cmp r12b, 0x6e ;n + je get_timestamp cmp r12b, 0x76 ;v jne die_usage DIE version_msg, version_len @@ -288,7 +291,9 @@ print_nfajr: movsd xmm14, xmm12 cmp r12b, byte 'u' je print_unix - CALC_DIFF xmm12 + + subsd xmm12, xmm6 ;diff = prayer time - tstamp = xmm12 + SEC_TO_HM xmm12 PRINT_EXIT print_fajr: @@ -296,7 +301,8 @@ print_fajr: movsd xmm14, xmm3 cmp r12b, byte 'u' je print_unix - CALC_DIFF xmm3 + subsd xmm3, xmm6 ;diff = prayer time - tstamp = xmm3 + SEC_TO_HM xmm3 PRINT_EXIT print_duhr: @@ -304,7 +310,10 @@ print_duhr: movsd xmm14, xmm0 cmp r12b, byte 'u' je print_unix - CALC_DIFF xmm0 + cmp r12b, byte 'n' + je print_24 + subsd xmm0, xmm6 ;diff = prayer time - tstamp = xmm0 + SEC_TO_HM xmm0 PRINT_EXIT print_asr: @@ -312,7 +321,10 @@ print_asr: movsd xmm14, xmm4 cmp r12b, byte 'u' je print_unix - CALC_DIFF xmm4 + cmp r12b, byte 'n' + je print_24 + subsd xmm4, xmm6 ;diff = prayer time - tstamp = xmm4 + SEC_TO_HM xmm4 PRINT_EXIT print_maghrib: @@ -320,7 +332,10 @@ print_maghrib: movsd xmm14, xmm5 cmp r12b, byte 'u' je print_unix - CALC_DIFF xmm5 + cmp r12b, byte 'n' + je print_24 + subsd xmm5, xmm6 ;diff = prayer time - tstamp = xmm5 + SEC_TO_HM xmm5 PRINT_EXIT print_isha: @@ -328,12 +343,20 @@ print_isha: movsd xmm14, xmm7 cmp r12b, byte 'u' je print_unix - CALC_DIFF xmm7 + cmp r12b, byte 'n' + je print_24 + subsd xmm7, xmm6 ;diff = prayer time - tstamp = xmm7 + SEC_TO_HM xmm7 PRINT_EXIT print_unix: PRINT_INT ;from xmm14 +print_24: + subsd xmm14, xmm15 ;prayer timestamp - start_of_day + SEC_TO_HM xmm14 + PRINT_EXIT + ; result_hour ;r8 ; result_min ;r9 ; duhr_ts: ;xmm0 @@ -346,6 +369,7 @@ print_unix: ; isha_ts: ;xmm7 ; D: ;xmm8 ; EqT: ;xmm9 +; macros: ;xmm10 ; next_fajr ;xmm12 ; duhr: ;xmm13 ; macros: ;xmm14 diff --git a/macros.s b/macros.s @@ -56,16 +56,16 @@ section .note.openbsd.ident note %endmacro %macro SEC_TO_HM 1 - ;hours = floor(diff / sec_inhour) = xmm15 - movsd xmm15, %1 - divsd xmm15, [sec_inhour] - roundsd xmm15, xmm15, ROUND_DOWN - cvtsd2si r8, xmm15 + ;hours = floor(diff / sec_inhour) = xmm10 + movsd xmm10, %1 + divsd xmm10, [sec_inhour] + roundsd xmm10, xmm10, ROUND_DOWN + cvtsd2si r8, xmm10 ;remaining_seconds = diff - (hours * sec_inhour) = xmm14 movsd xmm14, %1 - mulsd xmm15, [sec_inhour] - subsd xmm14, xmm15 + mulsd xmm10, [sec_inhour] + subsd xmm14, xmm10 ;minutes = remaining_seconds / sec_inmin divsd xmm14, [sec_inmin]