2018-11-23 07:03:26 +00:00
|
|
|
|
NEW
|
|
|
|
|
PREFIX
|
|
|
|
|
AUTO 4,1
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Uses: (pData)
|
|
|
|
|
* M32.ACC .BS 4
|
|
|
|
|
* M32.ARG .BS 4
|
|
|
|
|
* M32.TMP .BS 4
|
|
|
|
|
*--------------------------------------
|
2018-11-24 18:20:48 +00:00
|
|
|
|
* TODO : Make it SIGNED 32 bits
|
|
|
|
|
* TODO : Implement mul, div, mod ...
|
|
|
|
|
* http://6502.org/source/integers/32muldiv.htm
|
|
|
|
|
*--------------------------------------
|
2018-11-23 22:40:33 +00:00
|
|
|
|
M32.Add ldy #M32.ARG+4 ARG+ACC->ACC
|
2018-11-23 07:03:26 +00:00
|
|
|
|
|
2018-11-23 22:40:33 +00:00
|
|
|
|
.1 dey
|
|
|
|
|
lda (pData),y
|
|
|
|
|
pha
|
|
|
|
|
cpy #M32.ARG
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
ldy #M32.ACC
|
|
|
|
|
ldx #4
|
|
|
|
|
|
2018-11-23 07:03:26 +00:00
|
|
|
|
clc
|
|
|
|
|
|
2018-11-23 22:40:33 +00:00
|
|
|
|
.2 pla
|
|
|
|
|
adc (pData),y
|
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
2019-02-21 11:34:28 +00:00
|
|
|
|
clc
|
2018-11-23 07:03:26 +00:00
|
|
|
|
rts if CS, Overflow
|
|
|
|
|
*---------------------------------------
|
2018-11-24 22:25:33 +00:00
|
|
|
|
M32.Sub ldy #M32.ARG+4 ARG-ACC->ACC
|
2018-11-23 22:40:33 +00:00
|
|
|
|
|
|
|
|
|
.1 dey
|
|
|
|
|
lda (pData),y
|
|
|
|
|
pha
|
|
|
|
|
cpy #M32.ARG
|
2018-11-23 07:03:26 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
2018-11-23 22:40:33 +00:00
|
|
|
|
ldy #M32.ACC
|
|
|
|
|
ldx #4
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
|
|
|
|
|
.2 pla
|
|
|
|
|
sbc (pData),y
|
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
|
|
|
|
|
2019-02-21 11:34:28 +00:00
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2018-11-23 07:03:26 +00:00
|
|
|
|
bcs .8 if CC, Overflow
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
M32.Mul
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
M32.Div
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
M32.Mod
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-11-24 18:20:48 +00:00
|
|
|
|
M32.ACC2ARG ldy #M32.ACC+4 ACC->ARG
|
|
|
|
|
|
|
|
|
|
.1 dey
|
|
|
|
|
lda (pData),y
|
|
|
|
|
pha
|
|
|
|
|
cpy #M32.ACC
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
ldy #M32.ARG
|
|
|
|
|
|
|
|
|
|
.2 pla
|
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
cpy #M32.ARG+4
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-11-24 22:25:33 +00:00
|
|
|
|
M32.Cmp ldx #4
|
|
|
|
|
ldy #M32.ARG+3
|
|
|
|
|
|
|
|
|
|
.1 lda (pData),y
|
|
|
|
|
pha
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
ldx #4
|
|
|
|
|
ldy #M32.ACC
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
|
|
|
|
|
.2 pla
|
|
|
|
|
sbc (pData),y
|
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
bcc .5 CC if ACC < ARG
|
|
|
|
|
|
|
|
|
|
ldy #M32.ACC
|
|
|
|
|
|
|
|
|
|
lda (pData),y
|
|
|
|
|
iny
|
|
|
|
|
ora (pData),y
|
|
|
|
|
iny
|
|
|
|
|
ora (pData),y
|
|
|
|
|
iny
|
|
|
|
|
ora (pData),y Z if ACC = ARG
|
|
|
|
|
|
|
|
|
|
bne .4
|
|
|
|
|
|
2018-11-27 16:22:15 +00:00
|
|
|
|
lda #%010 010 ACC = ARG
|
2018-11-24 22:25:33 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2018-11-27 16:22:15 +00:00
|
|
|
|
.4 lda #%100 100 ACC > ARG
|
2018-11-24 22:25:33 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2018-11-27 16:22:15 +00:00
|
|
|
|
.5 lda #%001 001 ACC < ARG
|
2018-11-24 22:25:33 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-11-23 07:03:26 +00:00
|
|
|
|
MAN
|
|
|
|
|
SAVE USR/SRC/X.M32.S
|
2019-02-21 11:34:28 +00:00
|
|
|
|
LOAD USR/SRC/BIN/SH.S
|
2018-11-27 14:03:26 +00:00
|
|
|
|
ASM
|