A2osX/X.M32.S.txt
2018-11-27 17:22:15 +01:00

144 lines
2.2 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
PREFIX
AUTO 4,1
.LIST OFF
*--------------------------------------
* Uses: (pData)
* M32.ACC .BS 4
* M32.ARG .BS 4
* M32.TMP .BS 4
*--------------------------------------
* TODO : Make it SIGNED 32 bits
* TODO : Implement mul, div, mod ...
* http://6502.org/source/integers/32muldiv.htm
*--------------------------------------
M32.Add ldy #M32.ARG+4 ARG+ACC->ACC
.1 dey
lda (pData),y
pha
cpy #M32.ARG
bne .1
ldy #M32.ACC
ldx #4
clc
.2 pla
adc (pData),y
sta (pData),y
iny
dex
bne .2
rts if CS, Overflow
*---------------------------------------
M32.Sub ldy #M32.ARG+4 ARG-ACC->ACC
.1 dey
lda (pData),y
pha
cpy #M32.ARG
bne .1
ldy #M32.ACC
ldx #4
sec
.2 pla
sbc (pData),y
sta (pData),y
iny
dex
bne .2
bcs .8 if CC, Overflow
sec
rts
.8 clc
rts
*--------------------------------------
M32.Mul
*--------------------------------------
M32.Div
sec
rts
*--------------------------------------
M32.Mod
clc
rts
*--------------------------------------
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
*--------------------------------------
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
lda #%010 010 ACC = ARG
rts
.4 lda #%100 100 ACC > ARG
rts
.5 lda #%001 001 ACC < ARG
rts
*--------------------------------------
MAN
SAVE USR/SRC/X.M32.S
LOAD USR/SRC/BIN/SHELL.S
ASM