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/lib.r8asm
T
2026-06-10 20:58:41 +08:00

133 lines
1.5 KiB
Plaintext

;lib.r8asm
%macro step 1
stp %1
stp %1
%endmacro
%macro back 1
btp %1
btp %1
%endmacro
%macro set_0 0
biz
flb
rnz
%endmacro
%macro set_1 0
set_0
flb
%endmacro
%macro erase 0
%repeat _UNIT_SIZE
set_0
ror
%endrepeat
%endmacro
; Macro copy_to_buffer.
; %1: tmp
%macro copy_to_buffer 1
.anchor before_copy_to_buffer
stp
erase
.tp %1
erase
.tp before_copy_to_buffer
%repeat _UNIT_SIZE
biz
stp
set_1
.tp %1
set_1
.tp before_copy_to_buffer
flb
rnz
.tp before_copy_to_buffer
ror
stp
ror
.tp %1
ror
.tp before_copy_to_buffer
%endrepeat
.tp %1
%repeat _UNIT_SIZE
biz
.tp before_copy_to_buffer
set_1
.tp %1
flb
rnz
.tp before_copy_to_buffer
ror
.tp %1
ror
.tp %1
%endrepeat
.tp before_copy_to_buffer
%endmacro
; Macro unsafe_and
; %1: arg1
; %2: arg2
; %3: ans
%macro unsafe_and 3
.anchor before_unsafe_and
%repeat _UNIT_SIZE
.tp %1
biz
.tp %2
biz
.tp %3
set_1
.tp %2
set_0
rnz
.tp %1
set_0
rnz
.tp %1
ror
.tp %2
ror
.tp %3
ror
%endrepeat
.tp before_unsafe_and
%endmacro
; Macro and
; %1:unit1
; %2:unit2
; %3:ans_unit
%macro and 3
.anchor before_and
.tp %1
copy_to_buffer %3
stp ;Before r8asm_arg_stoi suppports evaluating,it's a compromise.
.anchor and_buf_1 ;
.tp %2
copy_to_buffer %3
stp ;
.anchor and_buf_2 ;
unsafe_and and_buf_1 and_buf_2 ans
.tp before_and
%endmacro