; ============================================================================
; 2進数8桁レジスタ 拡張命令
; ============================================================================
MBEB EQU 10H
; ----------------------------------------------------------------------------
; MOVR
; ----------------------------------------------------------------------------
MACRO MOVR _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IY
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; MOVI
; ----------------------------------------------------------------------------
MACRO MOVI _EBR,NUMBER
MOVX #0+MBEB
MOVI R0,NUMBER
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; ADD
; ----------------------------------------------------------------------------
MACRO ADD _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
ADD R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; SUB
; ----------------------------------------------------------------------------
MACRO SUB _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
SUB R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; ADDC
; ----------------------------------------------------------------------------
MACRO ADDC _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
ADDC R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; SUBC
; ----------------------------------------------------------------------------
MACRO SUBC _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
SUBC R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; SHU
; ----------------------------------------------------------------------------
MACRO SHU _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
SHU R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; SHD
; ----------------------------------------------------------------------------
MACRO SHD _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
SHD R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; ROU
; ----------------------------------------------------------------------------
MACRO ROU _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
ROU R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; ROD
; ----------------------------------------------------------------------------
MACRO ROD _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
ROD R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; CMP
; ----------------------------------------------------------------------------
MACRO CMP _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
CMP
ENDM
; ----------------------------------------------------------------------------
; AND
; ----------------------------------------------------------------------------
MACRO AND _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
AND R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; OR
; ----------------------------------------------------------------------------
MACRO OR _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
OR R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; XOR
; ----------------------------------------------------------------------------
MACRO XOR _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
XOR R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; NOT
; ----------------------------------------------------------------------------
MACRO NOT _EBR,_EBR
MOVX #0+MBEB
MOVY #1+MBEB
MOVMR R0,IX
MOVMR R1,IY
NOT R0,R1
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; INC
; ----------------------------------------------------------------------------
MACRO INC _EBR
MOVX #0+MBEB
MOVMR R0,IX
INC R0
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; DEC
; ----------------------------------------------------------------------------
MACRO DEC _EBR
MOVX #0+MBEB
MOVMR R0,IX
DEC R0
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; MOVRM
; ----------------------------------------------------------------------------
MACRO MOVRM (_ER),_EBR
MOVX #0*2+MBE
MOVY #1+MBEB
MOVMR R0,IX
INC IX
MOVMR R1,IX
MOVRX RP0
MOVMR R0,IY
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; MOVMR
; ----------------------------------------------------------------------------
MACRO MOVMR _EBR,(_ER)
MOVX #0+MBEB
MOVY #1*2+MBE
MOVMR R0,IY
INC IY
MOVMR R1,IY
MOVRY RP0
MOVMR R0,IY
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; MUL
; WORK0 行程
; 1,2 加算
; 3,4 累積
; ----------------------------------------------------------------------------
MACRO MUL _EBR,_EBR
MOVX WORK
MOVI R0,1
MOVRM IX,R0 ; 行程初期化
MOVX WORK+1
MOVY #1+MBEB
MOVMR R0,IY
MOVRM IX,R0
INC IX
XOR R0,R0
MOVRM IX,R0 ; 加算に乗数を設置
MOVX WORK+3
MOVRM IX,R0
INC IX
MOVRM IX,R0 ; 累積を初期化
MULB_X0: MOVX #0+MBEB
MOVMR R0,IX
MOVX WORK
MOVMR R1,IX
AND R0,R1
JMPZ MULB_X1 ; 加算なし
MOVX WORK+1
MOVY WORK+3
MOVMR R0,IX
MOVMR R1,IY
ADD R0,R1
MOVRM IY,R0
INC IX
INC IY
MOVMR R0,IX
MOVMR R1,IY
ADDC
MOVRM IY,R0 ; 累積
MULB_X1: MOVX WORK+1
MOVMR R0,IX
SHU R0,R0
MOVRM IX,R0
INC IX
MOVMR R0,IX
ROU
MOVRM IX,R0 ; 加算上移動
MOVX WORK
MOVMR R0,IX
SHU R0,R0
MOVRM IX,R0
JMPC MULB_X2 ; 終わり
JMP MULB_X0 ; 戻る
MULB_X2: MOVX #0+MBEB
MOVY WORK+3
MOVMR R0,IY
MOVRM IX,R0
MOVX #1+MBEB
INC IY
MOVMR R0,IY
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; DIV
; WORK0 行程
; 1,2 被除数移動
; 3 結果
; ----------------------------------------------------------------------------
MACRO DIV _EBR,_EBR
MOVY #1+MBEB
MOVX WORK
MOVI R0,1
MOVRM IX,R0 ; 行程初期化
MOVX WORK+3
XOR R0,R0
MOVRM IX,R0 ; 結果初期化
MOVX #0+MBEB
MOVMR R0,IX
MOVX WORK+1
MOVRM IX,R0
INC IX
XOR R0,R0
MOVRM IX,R0 ; 被除数設置
DIVB_X0:
MOVX WORK+1
MOVMR R0,IX
SHU R0,R0
MOVRM IX,R0
INC IX
MOVMR R0,IX
ROU
MOVRM IX,R0 ; 被除数上桁移動
MOVMR R0,IX
MOVMR R1,IY
CMP
JMPC DIVB_X1 ; 減算なし
SUB R0,R1
MOVRM IX,R0 ; 減算
MOVX WORK+3
MOVMR R0,IX
SHU R0,R0
MOVI R1,1
OR R0,R1
MOVRM IX,R0 ; 結果処理
JMP DIVB_X2 ; 次行程
MOVX WORK+1
MOVMR R0,IX
JMP DIVB_X0
DIVB_X1:
MOVX WORK+3
MOVMR R0,IX
SHU R0,R0
MOVRM IX,R0
DIVB_X2:
MOVX WORK
MOVMR R0,IX
SHU R0,R0
MOVRM IX,R0
JMPC DIVB_X3 ; 終了
JMP DIVB_X0 ; 戻る
DIVB_X3:
MOVX WORK+3
MOVMR R0,IX
MOVX #0+MBEB
MOVRM IX,R0
MOVX WORK+2
MOVMR R0,IX
MOVX #1+MBEB
MOVRM IX,R0
ENDM
; ============================================================================
; 2進数16桁レジスタ 拡張命令
; ============================================================================
MBE EQU MBEB+16
WORK EQU MBE+16
; ----------------------------------------------------------------------------
; DEC
; ----------------------------------------------------------------------------
MACRO DEC _ER
MOVX #0*2+MBE
MOVMR R0,IX
MOVI R1,1
SUB R0,R1
MOVRM IX,R0
INC IX
MOVMR R0,IX
MOVI R1,0
SUBC
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; INC
; ----------------------------------------------------------------------------
MACRO INC _ER
MOVX #0*2+MBE
MOVMR R0,IX
MOVI R1,1
ADD R0,R1
MOVRM IX,R0
INC IX
MOVMR R0,IX
MOVI R1,0
ADDC
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; MOVMR
; ----------------------------------------------------------------------------
MACRO MOVMR _ER,(_ER)
MOVX #1*2+MBE
MOVMR R0,IX
INC IX
MOVMR R1,IX
MOVRY RP0
MOVX #0*2+MBE
MOVMR R0,IY
MOVRM IX,R0
INC IX
INC IY
MOVMR R0,IY
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; MOVRM
; ----------------------------------------------------------------------------
MACRO MOVRM (_ER),_ER
MOVX #0*2+MBE
MOVMR R0,IX
INC IX
MOVMR R1,IX
MOVRX RP0
MOVY #1*2+MBE
MOVMR R0,IY
MOVRM IX,R0
INC IX
INC IY
MOVMR R0,IY
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; NOT
; ----------------------------------------------------------------------------
MACRO NOT _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IX
MOVMR R1,IY
NOT R0,R1
MOVRM IX,R0
INC IX
INC IY
LDSR
MOVR R2,R0
MOVMR R0,IX
MOVMR R1,IY
NOT R0,R1
MOVRM IX,R0
LDSR
AND R0,R2
PUSH R0
POP SR
ENDM
; ----------------------------------------------------------------------------
; XOR
; ----------------------------------------------------------------------------
MACRO XOR _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IX
MOVMR R1,IY
XOR R0,R1
MOVRM IX,R0
INC IX
INC IY
LDSR
MOVR R2,R0
MOVMR R0,IX
MOVMR R1,IY
XOR R0,R1
MOVRM IX,R0
LDSR
AND R0,R2
PUSH R0
POP SR
ENDM
; ----------------------------------------------------------------------------
; OR
; ----------------------------------------------------------------------------
MACRO OR _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IX
MOVMR R1,IY
OR R0,R1
MOVRM IX,R0
INC IX
INC IY
LDSR
MOVR R2,R0
MOVMR R0,IX
MOVMR R1,IY
OR R0,R1
MOVRM IX,R0
LDSR
AND R0,R2
PUSH R0
POP SR
ENDM
; ----------------------------------------------------------------------------
; AND
; ----------------------------------------------------------------------------
MACRO AND _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IX
MOVMR R1,IY
AND R0,R1
MOVRM IX,R0
INC IX
INC IY
LDSR
MOVR R2,R0
MOVMR R0,IX
MOVMR R1,IY
AND R0,R1
MOVRM IX,R0
LDSR
AND R0,R2
PUSH R0
POP SR
ENDM
; ----------------------------------------------------------------------------
; ROD
; ----------------------------------------------------------------------------
MACRO ROD _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IY
ROD
MOVRM IX,R0
INC IX
INC IY
MOVMR R0,IY
ROD
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; SHD
; ----------------------------------------------------------------------------
MACRO SHD _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IY
SHD R0,R0
MOVRM IX,R0
INC IX
INC IY
MOVMR R0,IY
ROD
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; CMP
; ----------------------------------------------------------------------------
MACRO CMP _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IX
MOVMR R1,IY
SUB R0,R1
INC IX
INC IY
LDSR
MOVI R1,80H
OR R0,R1
MOVR R2,R0
MOVMR R0,IX
MOVMR R1,IY
SUBC
LDSR
AND R0,R2
PUSH R0
POP SR
ENDM
; ----------------------------------------------------------------------------
; ROU
; ----------------------------------------------------------------------------
MACRO ROU _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IY
ROU
MOVRM IX,R0
INC IX
INC IY
MOVMR R0,IY
ROU
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; SHU
; ----------------------------------------------------------------------------
MACRO SHU _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IY
SHU R0,R0
MOVRM IX,R0
INC IX
INC IY
MOVMR R0,IY
ROU
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; SUBC
; ----------------------------------------------------------------------------
MACRO SUBC _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IX
MOVMR R1,IY
SUBC
MOVRM IX,R0
LDSR
MOVI R1,80H
OR R0,R1
MOVR R2,R0
INC IX
INC IY
MOVMR R0,IX
MOVMR R1,IY
SUBC
MOVRM IX,R0
LDSR
AND R0,R2
PUSH R0
POP SR
ENDM
; ----------------------------------------------------------------------------
; SUB
; ----------------------------------------------------------------------------
MACRO SUB _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IX
MOVMR R1,IY
SUB R0,R1
MOVRM IX,R0
LDSR
MOVI R1,80H
OR R0,R1
MOVR R2,R0
INC IX
INC IY
MOVMR R0,IX
MOVMR R1,IY
SUBC
MOVRM IX,R0
LDSR
AND R0,R2
PUSH R0
POP SR
ENDM
; ----------------------------------------------------------------------------
; MOVR
; ----------------------------------------------------------------------------
MACRO MOVR _ER,_ER
MOVX #1*2+MBE
MOVY #0*2+MBE
MOVMR R0,IX
MOVRM IY,R0
INC IX
INC IY
MOVMR R0,IX
MOVRM IY,R0
ENDM
; ----------------------------------------------------------------------------
; MOVI
; ----------------------------------------------------------------------------
MACRO MOVI _ER,NUMBER
MOVX #0*2+MBE
MOVI R0,#1&0FFH
MOVRM IX,R0
INC IX
MOVI R0,(#1>>8)&0FFH
MOVRM IX,R0
ENDM
; ----------------------------------------------------------------------------
; ADD
; ----------------------------------------------------------------------------
MACRO ADD _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IX
MOVMR R1,IY
ADD R0,R1
MOVRM IX,R0
LDSR
MOVI R1,80H
OR R0,R1
MOVR R2,R0
INC IX
INC IY
MOVMR R0,IX
MOVMR R1,IY
ADDC
MOVRM IX,R0
LDSR
AND R0,R2
PUSH R0
POP SR
ENDM
; ----------------------------------------------------------------------------
; ADDC
; ----------------------------------------------------------------------------
MACRO ADDC _ER,_ER
MOVX #0*2+MBE
MOVY #1*2+MBE
MOVMR R0,IX
MOVMR R1,IY
ADDC
MOVRM IX,R0
LDSR
MOVI R1,80H
OR R0,R1
MOVR R2,R0
INC IX
INC IY
MOVMR R0,IX
MOVMR R1,IY
ADDC
MOVRM IX,R0
LDSR
AND R0,R2
PUSH R0
POP SR
ENDM
; ----------------------------------------------------------------------------
; MUL
; 行程 WORK 0 - 1
; 累積 WORK 2 - 5
; 加数 WORK 6 - 9
; ----------------------------------------------------------------------------
MACRO MUL _ER,_ER
MOVX WORK
MOVI R0,1
MOVRM IX,R0 ; No.0
INC IX
XOR R0,R0
MOVRM IX,R0 ; No.1 行程初期化
MOVX WORK+2
MOVRM IX,R0 ; No.0
INC IX
MOVRM IX,R0 ; No.1
INC IX
MOVRM IX,R0 ; No.2
INC IX
MOVRM IX,R0 ; No.3 累積初期化
MOVX #1*2+MBE
MOVY WORK+6
MOVMR R0,IX
MOVRM IY,R0 ; No.0
INC IX
INC IY
MOVMR R0,IX
MOVRM IY,R0 ; No.1
INC IY
XOR R0,R0
MOVRM IY,R0 ; No.2
INC IY
MOVRM IY,R0 ; No.3 乗数設置
MUL_X0:
MOVX WORK
MOVY #0*2+MBE
MOVMR R0,IX
MOVMR R1,IY
AND R0,R1
JMPZ MUL_X1
JMP MUL_X2 ; 加算
MUL_X1:
INC IX
INC IY
MOVMR R0,IX
MOVMR R1,IY
AND R0,R1
JMPZ MUL_X3 ; 行程増
MUL_X2:
MOVX WORK+2
MOVY WORK+6
MOVMR R0,IX
MOVMR R1,IY
ADD R0,R1
MOVRM IX,R0 ; No.0
INC IX
INC IY
MOVMR R0,IX
MOVMR R1,IY
ADDC R0,R1
MOVRM IX,R0 ; No.1
INC IX
INC IY
MOVMR R0,IX
MOVMR R1,IY
ADDC R0,R1
MOVRM IX,R0 ; No.2
INC IX
INC IY
MOVMR R0,IX
MOVMR R1,IY
ADDC R0,R1
MOVRM IX,R0 ; NO.3 累積加算
MUL_X3:
MOVX WORK
MOVMR R0,IX
SHU R0,R0
MOVRM IX,R0 ; No.0
INC IX
MOVMR R0,IX
ROU R0,R0
MOVRM IX,R0 ; No.1 行程
JMPC MUL_X4 ; 終了
JMP MUL_X0 ; 戻る
MUL_X4:
MOVX #0*2+MBE
MOVY WORK+2
MOVMR R0,IY
MOVRM IX,R0 ; No.0
INC IX
INC IY
MOVMR R0,IY
MOVRM IX,R0 ; No.1
MOVX #1*2+MBE
INC IY
MOVMR R0,IY
MOVRM IX,R0 ; No.2
INC IX
INC IY
MOVMR R0,IY
MOVRM IX,R0 ; No.3
ENDM
|