Skip to content

Commit b70ff87

Browse files
committed
auspost: Harmonise ECC code with other encoders
1 parent d7a53d8 commit b70ff87

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/auspost.ps.src

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ begin
6363
(11) 37 (45) 37 (59) 52 (62) 67
6464
>> readonly def
6565

66+
/auspost.rsprod {
67+
64 mul add rstable exch get
68+
} bind def
69+
6670
/auspost.latevars dup 8 dict def load /init {
6771

6872
currentglobal
@@ -98,13 +102,17 @@ begin
98102
%
99103
/rspoly [ 1 0 0 0 0 ] def
100104
1 1 4 { % i
101-
1 1 index bitshift % t = 2^i
105+
1 1 index bitshift % t = 2^i
102106
exch -1 1 { % j = i -> 1
103-
rspoly 1 index 2 copy 1 sub get % ... rsploy j rsploy[j-1]
104-
rstable rspoly 6 -1 roll get 64 mul 5 index add get % p = rsploy[j] * t
105-
xor put % rspoly[j] = rsploy[j-1] ^ p
107+
rspoly 1 index 2 copy 1 sub get % ... rsploy j rsploy[j-1]
108+
rspoly 5 -1 roll get % ... rsploy[j]
109+
4 index % ... t
110+
//auspost.rsprod exec % p = rsploy[j] * t
111+
xor put % rspoly[j] = rsploy[j-1] ^ p
106112
} for
107-
rspoly 0 rstable 64 rspoly 0 get mul 4 index add get put % rspoly[0] = rspoly[0] * t
113+
rspoly 0 2 copy get % ... rspoly 0 rspoly[0]
114+
3 index % ... t
115+
//auspost.rsprod exec put % rspoly[0] = rspoly[0] * t
108116
pop % t
109117
} for
110118
/rspoly rspoly readonly def
@@ -255,9 +263,11 @@ begin
255263

256264
rscodes length 5 sub -1 0 { % i
257265
0 1 4 { % j
258-
rscodes 2 index 2 index add 2 copy get % ... rscodes i+j rscodes[i+j]
259-
rstable rspoly 6 -1 roll get 64 mul rscodes 6 index 4 add get add get % p = rspoly[j] * rscodes[i+4]
260-
xor put % rscodes[i+j] = rscodes[i+j] ^ p
266+
rscodes 2 index 2 index add 2 copy get % ... rscodes i+j rscodes[i+j]
267+
rspoly 5 -1 roll get % ... rspoly[j]
268+
rscodes 5 index 4 add get % ... rscodes[i+4]
269+
//auspost.rsprod exec % p = rspoly[j] * rscodes[i+4]
270+
xor put % rscodes[i+j] = rscodes[i+j] ^ p
261271
} for
262272
pop % i
263273
} for

0 commit comments

Comments
 (0)