Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use i8 instead of u8 for all types #50

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions asm/date_to_isoweekdate.asm
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
datealgo::asm::date_to_isoweekdate:
movabs rax, 281474976710655
and rax, rdi
mov rcx, rax
shr rcx, 32
cmp cl, 3
sbb edi, 0
movzx edx, cl
lea esi, [rdx + 12]
cmp cl, 3
cmovae esi, edx
shr rax, 40
add edi, 1468000
imul rcx, rdi, 1374389535
mov rdx, rcx
shr rdx, 37
imul edi, edi, 1461
shr edi, 2
mov rax, rdi
shr rax, 32
movsx ecx, al
lea edx, [rcx + 12]
xor esi, esi
cmp al, 3
setl sil
cmovge edx, ecx
mov eax, edi
sub eax, esi
add eax, 1468000
imul rcx, rax, 1374389535
mov rsi, rcx
shr rsi, 37
shr rdi, 16
sar edi, 24
imul eax, eax, 1461
shr eax, 2
shr rcx, 39
imul esi, esi, 979
add esi, -2919
shr esi, 5
sub eax, edx
add ecx, edi
imul edx, edx, 979
add edx, -2919
shr edx, 5
sub edi, esi
add ecx, eax
lea eax, [rcx + rsi]
add ecx, esi
add ecx, edi
lea eax, [rcx + rdx]
add ecx, edx
add ecx, -307
movsxd rcx, ecx
movabs rdx, 2635249153387078802
Expand Down
47 changes: 24 additions & 23 deletions asm/date_to_rd.asm
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
datealgo::asm::date_to_rd:
movabs rax, 281474976710655
and rax, rdi
mov rcx, rax
shr rcx, 32
cmp cl, 3
sbb edi, 0
movzx edx, cl
lea esi, [rdx + 12]
cmp cl, 3
cmovae esi, edx
shr rax, 40
add edi, 1468000
imul rcx, rdi, 1374389535
mov rdx, rcx
shr rdx, 37
imul edi, edi, 1461
shr edi, 2
mov rax, rdi
shr rax, 32
movsx ecx, al
lea edx, [rcx + 12]
xor esi, esi
cmp al, 3
cmovge edx, ecx
setl sil
mov eax, edi
sub eax, esi
add eax, 1468000
imul rcx, rax, 1374389535
mov rsi, rcx
shr rsi, 37
shr rdi, 16
sar edi, 24
imul eax, eax, 1461
shr eax, 2
shr rcx, 39
imul esi, esi, 979
add esi, -2919
shr esi, 5
sub eax, edx
add ecx, edi
imul edx, edx, 979
add edx, -2919
shr edx, 5
sub edi, esi
add ecx, eax
lea eax, [rsi + rcx]
add ecx, edi
lea eax, [rdx + rcx]
add eax, -536895459
ret
47 changes: 24 additions & 23 deletions asm/date_to_weekday.asm
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
datealgo::asm::date_to_weekday:
movabs rax, 281474976710655
and rax, rdi
mov rcx, rax
shr rcx, 32
cmp cl, 3
sbb edi, 0
movzx edx, cl
lea esi, [rdx + 12]
cmp cl, 3
cmovae esi, edx
shr rax, 40
add edi, 1468000
imul rcx, rdi, 1374389535
mov rdx, rcx
shr rdx, 37
lea edi, [rdi + 4*rdi]
shr edi, 2
mov rax, rdi
shr rax, 32
movsx ecx, al
lea edx, [rcx + 12]
xor esi, esi
cmp al, 3
setl sil
cmovge edx, ecx
mov eax, edi
sub eax, esi
add eax, 1468000
imul rcx, rax, 1374389535
mov rsi, rcx
shr rsi, 37
shr rdi, 16
sar edi, 24
lea eax, [rax + 4*rax]
shr eax, 2
shr rcx, 39
imul esi, esi, 979
add esi, -2855
shr esi, 5
sub eax, edx
add ecx, edi
imul edx, edx, 979
add edx, -2855
shr edx, 5
sub edi, esi
add ecx, eax
add ecx, esi
add ecx, edi
add ecx, edx
imul eax, ecx, 613566756
shr eax, 29
ret
25 changes: 13 additions & 12 deletions asm/datetime_to_secs.asm
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
datealgo::asm::datetime_to_secs:
mov ecx, dword ptr [rdi]
movzx eax, byte ptr [rdi + 4]
cmp eax, 3
sbb ecx, 0
movsx eax, byte ptr [rdi + 4]
lea edx, [rax + 12]
xor esi, esi
cmp eax, 3
cmovae edx, eax
movzx esi, byte ptr [rdi + 5]
setl sil
movsx r8d, byte ptr [rdi + 5]
cmovge edx, eax
sub ecx, esi
add ecx, 1468000
imul rax, rcx, 1374389535
mov r8, rax
shr r8, 37
mov rsi, rax
shr rsi, 37
imul r9d, ecx, 1461
shr r9d, 2
shr rax, 39
imul ecx, edx, 979
add ecx, -2919
shr ecx, 5
sub esi, r8d
sub r8d, esi
add eax, r9d
add eax, esi
add eax, r8d
lea edx, [rcx + rax]
add edx, -307
cmp edx, 1073719447
ja .LBB9_1
add eax, ecx
add eax, -536895459
movzx ecx, byte ptr [rdi + 8]
movzx edx, byte ptr [rdi + 7]
movzx esi, byte ptr [rdi + 6]
movsx rcx, byte ptr [rdi + 8]
movsx rdx, byte ptr [rdi + 7]
movsx rsi, byte ptr [rdi + 6]
cdqe
imul rdi, rax, 86400
imul rsi, rsi, 3600
Expand Down
57 changes: 29 additions & 28 deletions asm/datetime_to_systemtime.asm
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
datealgo::asm::datetime_to_systemtime:
movzx eax, byte ptr [rdi + 4]
cmp eax, 3
mov ecx, dword ptr [rdi]
movsx ecx, byte ptr [rdi + 4]
lea esi, [rcx + 12]
xor r8d, r8d
cmp ecx, 3
setl r8b
movsx eax, byte ptr [rdi + 5]
mov r9d, dword ptr [rdi]
mov edx, dword ptr [rdi + 12]
sbb ecx, 0
lea esi, [rax + 12]
cmp eax, 3
cmovae esi, eax
movzx r8d, byte ptr [rdi + 5]
add ecx, 1468000
imul rax, rcx, 1374389535
mov r9, rax
shr r9, 37
imul r10d, ecx, 1461
shr r10d, 2
shr rax, 39
imul ecx, esi, 979
add ecx, -2919
shr ecx, 5
sub r8d, r9d
add eax, r10d
add eax, r8d
lea esi, [rcx + rax]
add esi, -307
cmp esi, 1073719447
cmovge esi, ecx
sub r9d, r8d
add r9d, 1468000
imul rcx, r9, 1374389535
mov r8, rcx
shr r8, 37
imul r9d, r9d, 1461
shr r9d, 2
shr rcx, 39
imul esi, esi, 979
add esi, -2919
shr esi, 5
sub eax, r8d
add ecx, r9d
add ecx, eax
lea eax, [rsi + rcx]
add eax, -307
cmp eax, 1073719447
ja .LBB20_1
add eax, ecx
lea eax, [rsi + rcx]
add eax, -536895459
movzx ecx, byte ptr [rdi + 8]
movzx esi, byte ptr [rdi + 7]
movzx edi, byte ptr [rdi + 6]
movsx rcx, byte ptr [rdi + 8]
movsx rsi, byte ptr [rdi + 7]
movsx rdi, byte ptr [rdi + 6]
cdqe
imul rax, rax, 86400
imul rdi, rdi, 3600
Expand Down
2 changes: 1 addition & 1 deletion asm/days_in_month.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ datealgo::asm::days_in_month:
ret
.LBB11_2:
mov eax, esi
shr al, 3
sar al, 3
xor al, sil
or al, 30
ret
25 changes: 12 additions & 13 deletions asm/dhms_to_secs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ datealgo::asm::dhms_to_secs:
lea eax, [rdi + 536895152]
cmp eax, 1073719447
ja .LBB7_1
movsxd rax, edi
imul rcx, rax, 86400
mov rax, rdi
shr rax, 48
movzx eax, al
mov rcx, rdi
shr rcx, 40
mov rdx, rdi
shr rdx, 32
movsxd rsi, edi
imul rsi, rsi, 86400
add rsi, rax
movzx eax, dl
shr rax, 32
movsx rax, al
imul rdx, rax, 3600
add rdx, rsi
movzx eax, cl
imul rax, rax, 60
mov rax, rdi
shr rax, 40
movsx rax, al
imul rsi, rax, 60
shr rdi, 48
movsx rax, dil
add rax, rcx
add rax, rdx
add rax, rsi
ret
.LBB7_1:
xor eax, eax
Expand Down
45 changes: 21 additions & 24 deletions asm/isoweekdate_to_date.asm
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
datealgo::asm::isoweekdate_to_date:
mov rax, rdi
shr rax, 32
mov rcx, rdi
shr rcx, 40
movzx ecx, cl
add edi, 1467999
imul rdx, rdi, 1374389535
mov rsi, rdx
shr rsi, 37
imul edi, edi, 1461
shr edi, 2
shr rdx, 39
sub edx, esi
movzx eax, al
lea esi, [8*rax]
sub esi, eax
add esi, ecx
add esi, edi
add esi, edx
lea eax, [rdx + rdi]
lea ecx, [rdi + 1467999]
imul rax, rcx, 1374389535
mov rdx, rax
shr rdx, 37
imul ecx, ecx, 1461
shr ecx, 2
shr rax, 39
sub eax, edx
mov rdx, rdi
shr rdx, 8
sar edx, 24
lea esi, [8*rdx]
sub esi, edx
shr rdi, 16
sar edi, 24
add edi, esi
add edi, ecx
add edi, eax
add eax, ecx
add eax, 4
cdqe
movabs rcx, 2635249153387078802
imul rcx, rax
shr rcx, 61
dec ecx
movzx eax, cl
sub esi, eax
lea eax, [4*rsi + 1207]
sub edi, ecx
lea eax, [4*rdi + 1211]
imul rcx, rax, 963315389
shr rcx, 47
imul edx, ecx, 146097
Expand Down
Loading
Loading