Skip to content

Commit 2e7606b

Browse files
committed
small improvements in asm function
1 parent f2b7f81 commit 2e7606b

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

entries/hgrosser/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
**1 billion row Challenge entry**
44

55
## Version
6-
Version 1.50
6+
Version 1.51
77

88
## How to compile
99
The program was developed with FPC 3.2.2 and Lazarus 2.2.4
@@ -36,3 +36,4 @@ To speed things up:
3636

3737
- Version 1.00: initial version
3838
- Version 1.50: hash-list optimized, small improvements in parsing the file
39+
- Version 1.51: small improvements in asm function

entries/hgrosser/src/1brc.pas

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
sysutils, strutils, math;
2121

2222
const
23-
M_version = '1.50'; {version number}
23+
M_version = '1.51'; {version number}
2424

2525
{------------------------------ Common routines: ------------------------------}
2626

@@ -106,23 +106,20 @@ procedure error_halt(s: ansistring);
106106
{$ASMMODE INTEL}
107107

108108
function FPHashX_ASM(var buf; len: dword): dword; assembler; nostackframe;
109-
{returns a hash code similar to function FPHash() from FPC-Unit 'Contnrs',
110-
but with the difference, that all hash codes for all cities here are UNIQUE.
111-
I: len: MUST BE > 0!}
112-
// var buf = RDI
113-
// var len = ESI
109+
{returns a hash code similar to function FPHash() from FPC-Unit 'Contnrs',
110+
but with the difference, that all hash codes for all cities here are UNIQUE.
111+
I: len: MUST BE > 0!}
114112
asm
115-
MOV ECX,len
116113
MOV EAX,dword(-1)
117114

118115
@LOOP:
119116
MOV EDX,EAX // save Result
120117
SHL EAX,5 // eax := Result shl 5
121118
SUB EAX,EDX // eax := Result shl 5 - Result
122119

123-
XOR AL, [RDI]
124-
INC RDI
125-
DEC ECX
120+
XOR AL, [buf]
121+
INC buf
122+
DEC len
126123
JNZ @LOOP
127124
end; {FPHashX_ASM}
128125

0 commit comments

Comments
 (0)