finish macros

This commit is contained in:
Dmitry Vagner 2022-10-20 16:07:39 -04:00
parent 05fa0490b8
commit cad27241c1
2 changed files with 71 additions and 22 deletions

View File

@ -41,20 +41,24 @@ return_on_stack:
/// Note: f, f', g, g' consist of six terms on the stack
global mul_Fp12:
// stack: in1, in2, out
DUP1 %add_const(6) %load_fp6
// stack: f', in1, in2, out
DUP7 %add_const(6) %load_fp6
// stack: g', f', in1, in2, out
// stack: in1, in2, out
DUP1
%add_const(6)
%load_fp6
// stack: f', in1, in2, out
DUP7
%add_const(6)
%load_fp6
// stack: g', f', in1, in2, out
PUSH post_mul_1
DUP13 DUP13 DUP13 DUP13 DUP13 DUP13
%dup_fp6_7
// stack: f', post_mul_1, g', f', in1, in2, out
DUP13 DUP13 DUP13 DUP13 DUP13 DUP13
%dup_fp6_7
// stack: g', f', post_mul_1, g', f', in1, in2, out
%jump(mul_fp6)
post_mul_1:
// stack: f'g', g' , f', in1, in2, out
%dup1_fp6
%dup_fp6_0
// stack: f'g', f'g', g' , f', in1, in2, out
%store_fp6_sh(36)
// stack: f'g', g' , f', in1, in2, out
@ -62,11 +66,12 @@ post_mul_1:
// stack: g' , f', in1, in2, out
DUP13
// stack: in1, g' , f', in1, in2, out
DUP15 %load_fp6
DUP15
%load_fp6
// stack: g , in1, g' , f', in1, in2, out
%swap_fp6_hole
// stack: g', in1, g , f', in1, in2, out
DUP13 DUP13 DUP13 DUP13 DUP13 DUP13
dup_fp6_7
// stack: g,g', in1, g , f', in1, in2, out
%add_fp6
// stack: g+g', in1, g , f', in1, in2, out
@ -78,16 +83,17 @@ post_mul_1:
// stack: f, g, post_mul_2, g+g', f', in1, in2, out
%jump(mul_fp6)
post_mul_2:
// stack: fg, g+g', f', in1, in2, out
// stack: fg, g+g', f', in1, in2, out
%store_fp6(48)
// stack: g+g', f', in1, in2, out
// stack: g+g', f', in1, in2, out
%swap_fp6
// stack: f', g+g', in1, in2, out
// stack: f', g+g', in1, in2, out
PUSH post_mul_3
SWAP13 %load_fp6
// stack: f,f', g+g', post_mul_3, in2, out
SWAP13
%load_fp6
// stack: f,f', g+g', post_mul_3, in2, out
%add_fp6
// stack: f+f', g+g', post_mul_3, in2, out
// stack: f+f', g+g', post_mul_3, in2, out
%jump(mul_fp6)
post_mul_3:
// stack: (f+f')(g+g'), in2, out
@ -99,16 +105,20 @@ post_mul_3:
// stack: fg, (f+f')(g+g') - f'g', in2, out
%swap_fp6
// stack: (f+f')(g+g') - f'g', fg, in2, out
%dup2_fp6
%dup_fp6_6
// stack: fg, (f+f')(g+g') - f'g', fg, in2, out
%subr_fp6
// stack: (f+f')(g+g') - f'g' - fg, fg, in2, out
DUP14 add_const(6) %store_fp6
DUP14
add_const(6)
%store_fp6
// stack: fg, in2, out
%load_fp6(36)
// stack: sh(f'g') , fg, in2, out
%add_fp6
// stack: sh(f'g') + fg, in2, out
DUP8 %store_fp6
DUP8
%store_fp6
// stack: in2, out
%pop2 JUMP
%pop2
JUMP

View File

@ -171,7 +171,7 @@
%endmacro
// cost: 6
%macro dup1_fp6
%macro dup_fp6_0
// stack: f: 6
DUP6
DUP6
@ -183,7 +183,7 @@
%endmacro
// cost: 6
%macro dup2_fp6
%macro dup_fp6_6
// stack: f: 6, g: 6
DUP12
DUP12
@ -194,6 +194,18 @@
// stack: g: 6, f: 6, g: 6
%endmacro
// cost: 6
%macro dup_fp6_7
// stack: f: 6, g: 6
DUP13
DUP13
DUP13
DUP13
DUP13
DUP13
// stack: g: 6, f: 6, g: 6
%endmacro
// cost: 16
%macro swap_fp6
// stack: f0, f1, f2, f3, f4, f5, g0, g1, g2, g3, g4, g5
@ -221,6 +233,33 @@
// stack: g0, g1, g2, g3, g4, g5, f0, f1, f2, f3, f4, f5
%endmacro
// cost: 16
%macro swap_fp6_hole
// stack: f0, f1, f2, f3, f4, f5, X, g0, g1, g2, g3, g4, g5
SWAP7
// stack: g0, f1, f2, f3, f4, f5, X, f0, g1, g2, g3, g4, g5
SWAP1
SWAP8
SWAP1
// stack: g0, g1, f2, f3, f4, f5, X, f0, f1, g2, g3, g4, g5
SWAP2
SWAP9
SWAP2
// stack: g0, g1, g2, f3, f4, f5, X, f0, f1, f2, g3, g4, g5
SWAP3
SWAP10
SWAP3
// stack: g0, g1, g2, g3, f4, f5, X, f0, f1, f2, f3, g4, g5
SWAP4
SWAP11
SWAP4
// stack: g0, g1, g2, g3, g4, f5, X, f0, f1, f2, f3, f4, g5
SWAP5
SWAP12
SWAP5
// stack: g0, g1, g2, g3, g4, g5, X, f0, f1, f2, f3, f4, f5
%endmacro
// cost: 16
%macro add_fp6
// stack: f0, f1, f2, f3, f4, f5, g0, g1, g2, g3, g4, g5