This repository has been archived on 2026-09-29. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
R8ASM/asm/add.r8asm
T
2026-08-23 13:44:06 +08:00

137 lines
1.6 KiB
Plaintext

%include asm/lib.r8asm
; Macro bit_raw_add
; %1: CellBit A
; %2: CellBit B
; %3: CellBit Ci
; %4: CellBit S
; %5: CellBit Co
; %6: CellBit buf
%macro bit_raw_add 6
.anchor before_bit_raw_add
.tp %4
biz
flb
rnz
.tp %5
biz
flb
rnz
.tp %6
biz
flb
rnz
; sac=Ci: FLIP {A,B,buf}
.tp %3
biz
.tp %1
flb
.tp %2
flb
.tp %6
flb
.tp %3
flb
rnz
; sac=A: FLIP {Ci,S,buf}
.tp %1
biz
.tp %3
flb
.tp %4
flb
.tp %6
flb
.tp %1
flb
rnz
; sac=B: FLIP {A,Ci,Co,buf}
.tp %2
biz
.tp %1
flb
.tp %3
flb
.tp %5
flb
.tp %6
flb
.tp %2
flb
rnz
; sac=S: SET1 {B,Co}
.tp %4
biz
.tp %2
set_1
.tp %5
set_1
.tp %4
flb
rnz
; sac=buf: FLIP {A,B,Ci,S,Co}
.tp %6
biz
.tp %1
flb
.tp %2
flb
.tp %3
flb
.tp %4
flb
.tp %5
flb
.tp %6
flb
rnz
.tp before_bit_raw_add
%endmacro
; Macro raw_add
; %1: Cell A
; %2: Cell B
; %3: Cell Ci
; %4: Cell S
; %5: Cell Co
; %6: Cell tmp
%macro raw_add 6
.anchor before_raw_add
.tp %6
erase
.tp %3
bit_copy %6 %5
.tp %6
ror
%rep _CELL_SIZE
bit_raw_add %1 %2 %3 %4 %5 %6
.tp %5
clb_bit_mov %3
.tp %1
ror
.tp %2
ror
.tp %4
ror
%endrep
.tp %3
clb_bit_mov %5
.tp %6
rol
clb_bit_mov %3
.tp before_add
%endmacro