A2osX/INC/MACROS.I.txt
2020-08-23 21:46:37 +02:00

544 lines
9.1 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
AUTO 3,1
*--------------------------------------
.MA DEBUG
:1 bit $C000
bpl :1
sta $C010
.EM
*--------------------------------------
.MA DEBUGOA
bit $C061
bpl :1
>DEBUG
:1 .EQ *
.EM
*--------------------------------------
* SYSCALLs Macros
*--------------------------------------
.MA SYSCALL
ldx #SYS.]1
jsr A2osX.SYSCALL
.EM
*--------------------------------------
.MA LIBCALL
ldy ]1
ldx #]2
jsr A2osX.LIBCALL
.EM
*--------------------------------------
.MA SLEEP
jsr A2osX.SLEEP
.EM
*--------------------------------------
.MA SYSCALL2
ldx #SYS.]1
jsr A2osX.SYSCALL2
.EM
*--------------------------------------
.MA MLICALL
ldx #]1
.DO ]1=MLIALLOCIRQ
lda #2
.FIN
.DO ]1=MLIDEALLOCIRQ
lda #1
.FIN
.DO ]1=MLIATALK
lda #1
.FIN
.DO ]1=MLIREADBLOCK
lda #3
.FIN
.DO ]1=MLIWRITEBLOCK
lda #3
.FIN
.DO ]1=MLICREATE
lda #7
.FIN
.DO ]1=MLIDESTROY
lda #1
.FIN
.DO ]1=MLIRENAME
lda #2
.FIN
.DO ]1=MLISETFILEINFO
lda #7
.FIN
.DO ]1=MLIGETFILEINFO
lda #10
.FIN
.DO ]1=MLIONLINE
lda #2
.FIN
.DO ]1=MLISETPREFIX
lda #1
.FIN
.DO ]1=MLIGETPREFIX
lda #1
.FIN
.DO ]1=MLIOPEN
lda #3
.FIN
.DO ]1=MLINEWLINE
lda #3
.FIN
.DO ]1=MLIREAD
lda #4
.FIN
.DO ]1=MLIWRITE
lda #4
.FIN
.DO ]1=MLICLOSE
lda #1
.FIN
.DO ]1=MLIFLUSH
lda #1
.FIN
.DO ]1=MLISETMARK
lda #2
.FIN
.DO ]1=MLIGETMARK
lda #2
.FIN
.DO ]1=MLISETEOF
lda #2
.FIN
.DO ]1=MLIGETEOF
lda #2
.FIN
.DO ]1=MLISETBUF
lda #2
.FIN
.DO ]1=MLIGETBUF
lda #2
.FIN
.DO ]1=MLISETFILEINFOEX
lda #2
.FIN
.DO ]1=MLIGETFILEINFOEX
lda #2
.FIN
.DO ]1=MLIACL
lda #2
.FIN
jsr GP.MLICall
.EM
*--------------------------------------
* FPU Entry Point
*--------------------------------------
FPU.ADD32 .EQ 0
FPU.SUB32 .EQ 2
FPU.MUL32 .EQ 4
FPU.IMUL32 .EQ 6
FPU.DIV32 .EQ 8
FPU.IDIV32 .EQ 10
FPU.MOD32 .EQ 12
FPU.IMOD32 .EQ 14
FPU.CMP32 .EQ 16
FPU.ICMP32 .EQ 18
FPU.FADD .EQ 20
FPU.FSUB .EQ 22
FPU.FMULT .EQ 24
FPU.FDIV .EQ 26
FPU.PWR .EQ 28
FPU.LOG .EQ 30
FPU.SQR .EQ 32
FPU.EXP .EQ 34
FPU.COS .EQ 36
FPU.SIN .EQ 38
FPU.TAN .EQ 40
FPU.ATAN .EQ 42
FPU.SETARG .EQ 44 fadd.....
FPU.SETFAC .EQ 46 log...., PrintF
FPU.GETFAC .EQ 48 Copy FAC to (FORPNT)
FPU.FCOMP .EQ 50
FPU.LTOF .EQ 48 Float
FPU.QINT .EQ 50 lrintf
FPU.FIN .EQ 56 sscanf
FPU.FOUT .EQ 58 PrintF
*--------------------------------------
.MA FPU
ldx #FPU.]1
jsr A2osX.FPUCALL
.EM
*--------------------------------------
* Global DATA Segment Access
*--------------------------------------
.MA LEA.G
clc
lda pData
adc #]1
tay
lda pData+1
adc /]1
.EM
*--------------------------------------
.MA PUSHEA.G
>LEA.G ]1
>PUSHYA
.EM
*--------------------------------------
.MA PUSHB.G
ldy #]1
lda (pData),y
>PUSHA
.EM
*--------------------------------------
.MA PUSHW.G
ldy #]1+1
lda (pData),y
>PUSHA
dey
lda (pData),y
>PUSHA
.EM
*--------------------------------------
.MA PUSHL.G
ldy #]1+4
:1 dey
lda (pData),y
>PUSHA
cpy #]1
bne :1
.EM
*--------------------------------------
.MA PULLL.G
ldy #]1
:1 >PULLA
sta (pData),y
iny
cpy #]1+4
bne :1
.EM
*--------------------------------------
.MA PUSHF.G
ldy #]1+5
:1 dey
lda (pData),y
>PUSHA
cpy #]1
bne :1
.EM
*--------------------------------------
.MA PULLF.G
ldy #]1
:1 >PULLA
sta (pData),y
iny
cpy #]1+5
bne :1
.EM
*--------------------------------------
.MA LDA.G
ldy #]1
lda (pData),y
.EM
*--------------------------------------
.MA STZ.G
ldy #]1
lda #0
sta (pData),y
.EM
*--------------------------------------
.MA STA.G
ldy #]1
sta (pData),y
.EM
*--------------------------------------
.MA AND.G
ldy #]1
and (pData),y
.EM
*--------------------------------------
.MA ORA.G
ldy #]1
ora (pData),y
.EM
*--------------------------------------
.MA EOR.G
ldy #]1
eor (pData),y
.EM
*--------------------------------------
.MA CMP.G
ldy #]1
cmp (pData),y
.EM
*--------------------------------------
.MA ADC.G
ldy #]1
adc (pData),y
.EM
*--------------------------------------
.MA SBC.G
ldy #]1
sbc (pData),y
.EM
*--------------------------------------
.MA STZW.G
>STZ.G ]1
iny
sta (pData),y
.EM
*--------------------------------------
.MA INC.G
>LDA.G ]1
inc
sta (pData),y
.EM
*--------------------------------------
.MA INCW.G
>INC.G ]1
bne :1
iny
lda (pData),y
inc
sta (pData),y
:1 .EQ *
.EM
*--------------------------------------
.MA DEC.G
>LDA.G ]1
dec
sta (pData),y
.EM
*--------------------------------------
.MA DECW.G
>LDA.G ]1
bne :1
dec
sta (pData),y
iny
lda (pData),y
:1 dec
sta (pData),y
.EM
*--------------------------------------
.MA LDYA.G
>LDA.G ]1
pha
iny
lda (pData),y
ply
.EM
*--------------------------------------
.MA STYA.G
phy
ldy #]1+1
sta (pData),y
dey
pla
sta (pData),y
.EM
*--------------------------------------
* STACK PUSH/PULL
*--------------------------------------
.MA PUSHA
dec pStack
sta (pStack)
.EM
*--------------------------------------
.MA PULLA
lda (pStack)
inc pStack
.EM
*--------------------------------------
.MA PUSHYA
>PUSHA
tya
>PUSHA
.EM
*--------------------------------------
.MA PULLYA
>PULLA
tay
>PULLA
.EM
*--------------------------------------
.MA PUSHBI
lda #]1
>PUSHA
.EM
*--------------------------------------
.MA PUSHB
.DO ]#=2
lda ]1,]2
>PUSHA
.ELSE
lda ]1
>PUSHA
.FIN
.EM
*--------------------------------------
.MA PULLB
.DO ]#=2
>PULLA
sta ]1,]2
.ELSE
>PULLA
sta ]1
.FIN
.EM
*--------------------------------------
.MA PUSHWZ
lda #0
>PUSHA
>PUSHA
.EM
*--------------------------------------
.MA PUSHWI
lda /]1
>PUSHA
lda #]1
>PUSHA
.EM
*--------------------------------------
.MA PUSHW
.DO ]#=2
lda ]1+1,]2
>PUSHA
lda ]1,]2
>PUSHA
.ELSE
lda ]1+1
>PUSHA
lda ]1
>PUSHA
.FIN
.EM
*--------------------------------------
.MA PULLW
>PULLA
sta ]1
>PULLA
sta ]1+1
.EM
*--------------------------------------
.MA PUSHL
ldy #3
:1 lda ]1,y
>PUSHA
dey
bpl :1
.EM
*--------------------------------------
.MA PULLL
ldy #0
:1 >PULLA
sta ]1,y
iny
cpy #4
bne :1
.EM
*--------------------------------------
.MA PUSHF
ldy #4
:1 lda ]1,y
>PUSHA
dey
bpl :1
.EM
*--------------------------------------
.MA PULLF
ldy #0
:1 >PULLA
sta ]1,y
iny
cpy #5
bne :1
.EM
*--------------------------------------
.MA ENTER
>PUSHB pBase
lda pStack
sta pBase
sec
sbc #]1
sta pStack
.EM
*--------------------------------------
.MA LEAVE
pha
lda pStack
sta pBase
>PULLB pBase
pla
.EM
*--------------------------------------
.MA POP
.DO ]1=1
inc pStack
.FIN
.DO ]1=2
inc pStack
inc pStack
.FIN
.DO ]1=3
inc pStack
inc pStack
inc pStack
.FIN
.DO ]1>3
pha
lda #]1
:1 inc pStack
dec
bne :1
pla
.FIN
.EM
*--------------------------------------
.MA RET
>POP ]1
rts
.EM
*--------------------------------------
* General WORD Manipulation Macros
*--------------------------------------
.MA LDYAI
ldy #]1
lda /]1
.EM
*--------------------------------------
.MA LDYA
.DO ]#=2
ldy ]1,]2
lda ]1+1,]2
.ELSE
ldy ]1
lda ]1+1
.FIN
.EM
*--------------------------------------
.MA STYA
.DO ]#=2
sta ]1+1,]2
tya
sta ]1,]2
.ELSE
sty ]1
sta ]1+1
.FIN
.EM
*--------------------------------------
* General Strings Macros
*--------------------------------------
.MA PSTR
.DA #:1-*-1
.AS "]1"
:1 .EQ *
.EM
*--------------------------------------
MAN
SAVE inc/macros.i