mirror of
https://github.com/irmen/prog8.git
synced 2025-02-25 04:29:36 +00:00
rol and ror
This commit is contained in:
parent
661c757236
commit
d0bd2f522c
@ -149,5 +149,6 @@ sub print_f (float value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
%asminclude "library:c64/floats.asm", ""
|
%asminclude "library:c64/floats.asm", ""
|
||||||
|
%asminclude "library:c64/floats_funcs.asm", ""
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -743,12 +743,9 @@ _done rts
|
|||||||
|
|
||||||
|
|
||||||
ror2_mem_ub .proc
|
ror2_mem_ub .proc
|
||||||
; -- in-place 8-bit ror of byte at memory location on stack
|
; -- in-place 8-bit ror of byte at memory location in AY
|
||||||
inx
|
|
||||||
lda P8ESTACK_LO,x
|
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
||||||
lda P8ESTACK_HI,x
|
sty P8ZP_SCRATCH_W1+1
|
||||||
sta P8ZP_SCRATCH_W1+1
|
|
||||||
ldy #0
|
ldy #0
|
||||||
lda (P8ZP_SCRATCH_W1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
lsr a
|
lsr a
|
||||||
@ -759,12 +756,9 @@ ror2_mem_ub .proc
|
|||||||
.pend
|
.pend
|
||||||
|
|
||||||
rol2_mem_ub .proc
|
rol2_mem_ub .proc
|
||||||
; -- in-place 8-bit rol of byte at memory location on stack
|
; -- in-place 8-bit rol of byte at memory location in AY
|
||||||
inx
|
|
||||||
lda P8ESTACK_LO,x
|
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
||||||
lda P8ESTACK_HI,x
|
sty P8ZP_SCRATCH_W1+1
|
||||||
sta P8ZP_SCRATCH_W1+1
|
|
||||||
ldy #0
|
ldy #0
|
||||||
lda (P8ZP_SCRATCH_W1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
cmp #$80
|
cmp #$80
|
||||||
@ -774,81 +768,79 @@ rol2_mem_ub .proc
|
|||||||
.pend
|
.pend
|
||||||
|
|
||||||
rol_array_ub .proc
|
rol_array_ub .proc
|
||||||
; -- rol a ubyte in an array (index and array address on stack)
|
; -- rol a ubyte in an array
|
||||||
inx
|
lda _arg_target
|
||||||
ldy P8ESTACK_LO,x
|
ldy _arg_target+1
|
||||||
inx
|
|
||||||
lda P8ESTACK_LO,x
|
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
||||||
lda P8ESTACK_HI,x
|
sty P8ZP_SCRATCH_W1+1
|
||||||
sta P8ZP_SCRATCH_W1+1
|
ldy _arg_index
|
||||||
lda (P8ZP_SCRATCH_W1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
rol a
|
rol a
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
rts
|
rts
|
||||||
|
_arg_target .word 0
|
||||||
|
_arg_index .byte 0
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
|
|
||||||
ror_array_ub .proc
|
ror_array_ub .proc
|
||||||
; -- ror a ubyte in an array (index and array address on stack)
|
; -- ror a ubyte in an array
|
||||||
inx
|
lda _arg_target
|
||||||
ldy P8ESTACK_LO,x
|
ldy _arg_target+1
|
||||||
inx
|
|
||||||
lda P8ESTACK_LO,x
|
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
||||||
lda P8ESTACK_HI,x
|
sty P8ZP_SCRATCH_W1+1
|
||||||
sta P8ZP_SCRATCH_W1+1
|
ldy _arg_index
|
||||||
lda (P8ZP_SCRATCH_W1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
ror a
|
ror a
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
rts
|
rts
|
||||||
|
_arg_target .word 0
|
||||||
|
_arg_index .byte 0
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
ror2_array_ub .proc
|
ror2_array_ub .proc
|
||||||
; -- ror2 (8-bit ror) a ubyte in an array (index and array address on stack)
|
; -- ror2 (8-bit ror) a ubyte in an array
|
||||||
inx
|
lda _arg_target
|
||||||
ldy P8ESTACK_LO,x
|
ldy _arg_target+1
|
||||||
inx
|
|
||||||
lda P8ESTACK_LO,x
|
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
||||||
lda P8ESTACK_HI,x
|
sty P8ZP_SCRATCH_W1+1
|
||||||
sta P8ZP_SCRATCH_W1+1
|
ldy _arg_index
|
||||||
lda (P8ZP_SCRATCH_W1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
lsr a
|
lsr a
|
||||||
bcc +
|
bcc +
|
||||||
ora #$80
|
ora #$80
|
||||||
+ sta (P8ZP_SCRATCH_W1),y
|
+ sta (P8ZP_SCRATCH_W1),y
|
||||||
rts
|
rts
|
||||||
|
_arg_target .word 0
|
||||||
|
_arg_index .byte 0
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
rol2_array_ub .proc
|
rol2_array_ub .proc
|
||||||
; -- rol2 (8-bit rol) a ubyte in an array (index and array address on stack)
|
; -- rol2 (8-bit rol) a ubyte in an array
|
||||||
inx
|
lda _arg_target
|
||||||
ldy P8ESTACK_LO,x
|
ldy _arg_target+1
|
||||||
inx
|
|
||||||
lda P8ESTACK_LO,x
|
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
||||||
lda P8ESTACK_HI,x
|
sty P8ZP_SCRATCH_W1+1
|
||||||
sta P8ZP_SCRATCH_W1+1
|
ldy _arg_index
|
||||||
lda (P8ZP_SCRATCH_W1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
cmp #$80
|
cmp #$80
|
||||||
rol a
|
rol a
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
rts
|
rts
|
||||||
|
_arg_target .word 0
|
||||||
|
_arg_index .byte 0
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
ror_array_uw .proc
|
ror_array_uw .proc
|
||||||
; -- ror a uword in an array (index and array address on stack)
|
; -- ror a uword in an array
|
||||||
php
|
php
|
||||||
inx
|
lda _arg_target
|
||||||
lda P8ESTACK_LO,x
|
ldy _arg_target+1
|
||||||
|
sta P8ZP_SCRATCH_W1
|
||||||
|
sty P8ZP_SCRATCH_W1+1
|
||||||
|
lda _arg_index
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
inx
|
|
||||||
lda P8ESTACK_LO,x
|
|
||||||
sta P8ZP_SCRATCH_W1
|
|
||||||
lda P8ESTACK_HI,x
|
|
||||||
sta P8ZP_SCRATCH_W1+1
|
|
||||||
iny
|
iny
|
||||||
lda (P8ZP_SCRATCH_W1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
plp
|
plp
|
||||||
@ -859,20 +851,20 @@ ror_array_uw .proc
|
|||||||
ror a
|
ror a
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
rts
|
rts
|
||||||
|
_arg_target .word 0
|
||||||
|
_arg_index .byte 0
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
rol_array_uw .proc
|
rol_array_uw .proc
|
||||||
; -- rol a uword in an array (index and array address on stack)
|
; -- rol a uword in an array
|
||||||
php
|
php
|
||||||
inx
|
lda _arg_target
|
||||||
lda P8ESTACK_LO,x
|
ldy _arg_target+1
|
||||||
|
sta P8ZP_SCRATCH_W1
|
||||||
|
sty P8ZP_SCRATCH_W1+1
|
||||||
|
lda _arg_index
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
inx
|
|
||||||
lda P8ESTACK_LO,x
|
|
||||||
sta P8ZP_SCRATCH_W1
|
|
||||||
lda P8ESTACK_HI,x
|
|
||||||
sta P8ZP_SCRATCH_W1+1
|
|
||||||
lda (P8ZP_SCRATCH_W1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
plp
|
plp
|
||||||
rol a
|
rol a
|
||||||
@ -882,19 +874,19 @@ rol_array_uw .proc
|
|||||||
rol a
|
rol a
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
rts
|
rts
|
||||||
|
_arg_target .word 0
|
||||||
|
_arg_index .byte 0
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
rol2_array_uw .proc
|
rol2_array_uw .proc
|
||||||
; -- rol2 (16-bit rol) a uword in an array (index and array address on stack)
|
; -- rol2 (16-bit rol) a uword in an array
|
||||||
inx
|
lda _arg_target
|
||||||
lda P8ESTACK_LO,x
|
ldy _arg_target+1
|
||||||
|
sta P8ZP_SCRATCH_W1
|
||||||
|
sty P8ZP_SCRATCH_W1+1
|
||||||
|
lda _arg_index
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
inx
|
|
||||||
lda P8ESTACK_LO,x
|
|
||||||
sta P8ZP_SCRATCH_W1
|
|
||||||
lda P8ESTACK_HI,x
|
|
||||||
sta P8ZP_SCRATCH_W1+1
|
|
||||||
lda (P8ZP_SCRATCH_W1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
asl a
|
asl a
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
@ -908,19 +900,19 @@ rol2_array_uw .proc
|
|||||||
adc #0
|
adc #0
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
+ rts
|
+ rts
|
||||||
|
_arg_target .word 0
|
||||||
|
_arg_index .byte 0
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
ror2_array_uw .proc
|
ror2_array_uw .proc
|
||||||
; -- ror2 (16-bit ror) a uword in an array (index and array address on stack)
|
; -- ror2 (16-bit ror) a uword in an array
|
||||||
inx
|
lda _arg_target
|
||||||
lda P8ESTACK_LO,x
|
ldy _arg_target+1
|
||||||
|
sta P8ZP_SCRATCH_W1
|
||||||
|
sty P8ZP_SCRATCH_W1+1
|
||||||
|
lda _arg_index
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
inx
|
|
||||||
lda P8ESTACK_LO,x
|
|
||||||
sta P8ZP_SCRATCH_W1
|
|
||||||
lda P8ESTACK_HI,x
|
|
||||||
sta P8ZP_SCRATCH_W1+1
|
|
||||||
iny
|
iny
|
||||||
lda (P8ZP_SCRATCH_W1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
lsr a
|
lsr a
|
||||||
@ -935,6 +927,8 @@ ror2_array_uw .proc
|
|||||||
ora #$80
|
ora #$80
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
+ rts
|
+ rts
|
||||||
|
_arg_target .word 0
|
||||||
|
_arg_index .byte 0
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
|
|
||||||
@ -945,7 +939,6 @@ strcpy .proc
|
|||||||
sty P8ZP_SCRATCH_W2+1
|
sty P8ZP_SCRATCH_W2+1
|
||||||
ldy #$ff
|
ldy #$ff
|
||||||
- iny
|
- iny
|
||||||
inc $d020
|
|
||||||
lda (P8ZP_SCRATCH_W2),y
|
lda (P8ZP_SCRATCH_W2),y
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
bne -
|
bne -
|
||||||
|
@ -5,6 +5,7 @@ import prog8.ast.Node
|
|||||||
import prog8.ast.Program
|
import prog8.ast.Program
|
||||||
import prog8.ast.base.*
|
import prog8.ast.base.*
|
||||||
import prog8.ast.expressions.*
|
import prog8.ast.expressions.*
|
||||||
|
import prog8.ast.statements.ArrayIndex
|
||||||
import prog8.ast.statements.DirectMemoryWrite
|
import prog8.ast.statements.DirectMemoryWrite
|
||||||
import prog8.ast.statements.FunctionCallStatement
|
import prog8.ast.statements.FunctionCallStatement
|
||||||
import prog8.compiler.AssemblyError
|
import prog8.compiler.AssemblyError
|
||||||
@ -268,17 +269,16 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
DataType.UBYTE -> {
|
DataType.UBYTE -> {
|
||||||
when (what) {
|
when (what) {
|
||||||
is ArrayIndexedExpression -> {
|
is ArrayIndexedExpression -> {
|
||||||
asmgen.translateExpression(what.arrayvar)
|
translateRolRorArrayArgs(what.arrayvar, what.indexer, fcall, "ror2", 'b')
|
||||||
asmgen.translateExpression(what.indexer)
|
asmgen.out(" jsr prog8_lib.ror2_array_ub")
|
||||||
asmgen.out(" jsr prog8_lib.ror2_array_ub_cc") // TODO cc
|
|
||||||
}
|
}
|
||||||
is DirectMemoryRead -> {
|
is DirectMemoryRead -> {
|
||||||
if (what.addressExpression is NumericLiteralValue) {
|
if (what.addressExpression is NumericLiteralValue) {
|
||||||
val number = (what.addressExpression as NumericLiteralValue).number
|
val number = (what.addressExpression as NumericLiteralValue).number
|
||||||
asmgen.out(" lda ${number.toHex()} | lsr a | bcc + | ora #\$80 |+ | sta ${number.toHex()}")
|
asmgen.out(" lda ${number.toHex()} | lsr a | bcc + | ora #\$80 |+ | sta ${number.toHex()}")
|
||||||
} else {
|
} else {
|
||||||
asmgen.translateExpression(what.addressExpression)
|
translateRolRorMemoryArgs(what.addressExpression, fcall)
|
||||||
asmgen.out(" jsr prog8_lib.ror2_mem_ub_cc") // TODO cc
|
asmgen.out(" jsr prog8_lib.ror2_mem_ub")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is IdentifierReference -> {
|
is IdentifierReference -> {
|
||||||
@ -291,10 +291,8 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
DataType.UWORD -> {
|
DataType.UWORD -> {
|
||||||
when (what) {
|
when (what) {
|
||||||
is ArrayIndexedExpression -> {
|
is ArrayIndexedExpression -> {
|
||||||
// TODO cc
|
translateRolRorArrayArgs(what.arrayvar, what.indexer, fcall, "ror2", 'w')
|
||||||
asmgen.translateExpression(what.arrayvar)
|
asmgen.out(" jsr prog8_lib.ror2_array_uw")
|
||||||
asmgen.translateExpression(what.indexer)
|
|
||||||
asmgen.out(" jsr prog8_lib.ror2_array_uw_cc")
|
|
||||||
}
|
}
|
||||||
is IdentifierReference -> {
|
is IdentifierReference -> {
|
||||||
val variable = asmgen.asmVariableName(what)
|
val variable = asmgen.asmVariableName(what)
|
||||||
@ -314,26 +312,19 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
DataType.UBYTE -> {
|
DataType.UBYTE -> {
|
||||||
when (what) {
|
when (what) {
|
||||||
is ArrayIndexedExpression -> {
|
is ArrayIndexedExpression -> {
|
||||||
// TODO cc
|
translateRolRorArrayArgs(what.arrayvar, what.indexer, fcall, "ror", 'b')
|
||||||
asmgen.translateExpression(what.arrayvar)
|
asmgen.out(" jsr prog8_lib.ror_array_ub")
|
||||||
asmgen.translateExpression(what.indexer)
|
|
||||||
asmgen.out(" jsr prog8_lib.ror_array_ub_cc")
|
|
||||||
}
|
}
|
||||||
is DirectMemoryRead -> {
|
is DirectMemoryRead -> {
|
||||||
if (what.addressExpression is NumericLiteralValue) {
|
if (what.addressExpression is NumericLiteralValue) {
|
||||||
val number = (what.addressExpression as NumericLiteralValue).number
|
val number = (what.addressExpression as NumericLiteralValue).number
|
||||||
asmgen.out(" ror ${number.toHex()}")
|
asmgen.out(" ror ${number.toHex()}")
|
||||||
} else {
|
} else {
|
||||||
// TODO cc
|
translateRolRorMemoryArgs(what.addressExpression, fcall)
|
||||||
asmgen.translateExpression(what.addressExpression)
|
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
inx
|
sta (+) + 1
|
||||||
lda P8ESTACK_LO,x
|
sty (+) + 2
|
||||||
sta (+) + 1
|
+ ror ${'$'}ffff ; modified""")
|
||||||
lda P8ESTACK_HI,x
|
|
||||||
sta (+) + 2
|
|
||||||
+ ror ${'$'}ffff ; modified
|
|
||||||
""")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is IdentifierReference -> {
|
is IdentifierReference -> {
|
||||||
@ -346,10 +337,8 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
DataType.UWORD -> {
|
DataType.UWORD -> {
|
||||||
when (what) {
|
when (what) {
|
||||||
is ArrayIndexedExpression -> {
|
is ArrayIndexedExpression -> {
|
||||||
// TODO cc
|
translateRolRorArrayArgs(what.arrayvar, what.indexer, fcall, "ror", 'w')
|
||||||
asmgen.translateExpression(what.arrayvar)
|
asmgen.out(" jsr prog8_lib.ror_array_uw")
|
||||||
asmgen.translateExpression(what.indexer)
|
|
||||||
asmgen.out(" jsr prog8_lib.ror_array_uw_cc")
|
|
||||||
}
|
}
|
||||||
is IdentifierReference -> {
|
is IdentifierReference -> {
|
||||||
val variable = asmgen.asmVariableName(what)
|
val variable = asmgen.asmVariableName(what)
|
||||||
@ -369,19 +358,16 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
DataType.UBYTE -> {
|
DataType.UBYTE -> {
|
||||||
when (what) {
|
when (what) {
|
||||||
is ArrayIndexedExpression -> {
|
is ArrayIndexedExpression -> {
|
||||||
// TODO cc
|
translateRolRorArrayArgs(what.arrayvar, what.indexer, fcall, "rol2", 'b')
|
||||||
asmgen.translateExpression(what.arrayvar)
|
asmgen.out(" jsr prog8_lib.rol2_array_ub")
|
||||||
asmgen.translateExpression(what.indexer)
|
|
||||||
asmgen.out(" jsr prog8_lib.rol2_array_ub_cc")
|
|
||||||
}
|
}
|
||||||
is DirectMemoryRead -> {
|
is DirectMemoryRead -> {
|
||||||
if (what.addressExpression is NumericLiteralValue) {
|
if (what.addressExpression is NumericLiteralValue) {
|
||||||
val number = (what.addressExpression as NumericLiteralValue).number
|
val number = (what.addressExpression as NumericLiteralValue).number
|
||||||
asmgen.out(" lda ${number.toHex()} | cmp #\$80 | rol a | sta ${number.toHex()}")
|
asmgen.out(" lda ${number.toHex()} | cmp #\$80 | rol a | sta ${number.toHex()}")
|
||||||
} else {
|
} else {
|
||||||
// TODO cc
|
translateRolRorMemoryArgs(what.addressExpression, fcall)
|
||||||
asmgen.translateExpression(what.addressExpression)
|
asmgen.out(" jsr prog8_lib.rol2_mem_ub")
|
||||||
asmgen.out(" jsr prog8_lib.rol2_mem_ub_cc")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is IdentifierReference -> {
|
is IdentifierReference -> {
|
||||||
@ -394,10 +380,8 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
DataType.UWORD -> {
|
DataType.UWORD -> {
|
||||||
when (what) {
|
when (what) {
|
||||||
is ArrayIndexedExpression -> {
|
is ArrayIndexedExpression -> {
|
||||||
// TODO cc
|
translateRolRorArrayArgs(what.arrayvar, what.indexer, fcall, "rol2", 'w')
|
||||||
asmgen.translateExpression(what.arrayvar)
|
asmgen.out(" jsr prog8_lib.rol2_array_uw")
|
||||||
asmgen.translateExpression(what.indexer)
|
|
||||||
asmgen.out(" jsr prog8_lib.rol2_array_uw_cc")
|
|
||||||
}
|
}
|
||||||
is IdentifierReference -> {
|
is IdentifierReference -> {
|
||||||
val variable = asmgen.asmVariableName(what)
|
val variable = asmgen.asmVariableName(what)
|
||||||
@ -417,26 +401,19 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
DataType.UBYTE -> {
|
DataType.UBYTE -> {
|
||||||
when (what) {
|
when (what) {
|
||||||
is ArrayIndexedExpression -> {
|
is ArrayIndexedExpression -> {
|
||||||
// TODO cc
|
translateRolRorArrayArgs(what.arrayvar, what.indexer, fcall, "rol", 'b')
|
||||||
asmgen.translateExpression(what.arrayvar)
|
asmgen.out(" jsr prog8_lib.rol_array_ub")
|
||||||
asmgen.translateExpression(what.indexer)
|
|
||||||
asmgen.out(" jsr prog8_lib.rol_array_ub_cc")
|
|
||||||
}
|
}
|
||||||
is DirectMemoryRead -> {
|
is DirectMemoryRead -> {
|
||||||
if (what.addressExpression is NumericLiteralValue) {
|
if (what.addressExpression is NumericLiteralValue) {
|
||||||
val number = (what.addressExpression as NumericLiteralValue).number
|
val number = (what.addressExpression as NumericLiteralValue).number
|
||||||
asmgen.out(" rol ${number.toHex()}")
|
asmgen.out(" rol ${number.toHex()}")
|
||||||
} else {
|
} else {
|
||||||
// TODO cc
|
translateRolRorMemoryArgs(what.addressExpression, fcall)
|
||||||
asmgen.translateExpression(what.addressExpression)
|
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
inx
|
sta (+) + 1
|
||||||
lda P8ESTACK_LO,x
|
sty (+) + 2
|
||||||
sta (+) + 1
|
+ rol ${'$'}ffff ; modified""")
|
||||||
lda P8ESTACK_HI,x
|
|
||||||
sta (+) + 2
|
|
||||||
+ rol ${'$'}ffff ; modified
|
|
||||||
""")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is IdentifierReference -> {
|
is IdentifierReference -> {
|
||||||
@ -449,10 +426,8 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
DataType.UWORD -> {
|
DataType.UWORD -> {
|
||||||
when (what) {
|
when (what) {
|
||||||
is ArrayIndexedExpression -> {
|
is ArrayIndexedExpression -> {
|
||||||
// TODO cc
|
translateRolRorArrayArgs(what.arrayvar, what.indexer, fcall, "rol", 'w')
|
||||||
asmgen.translateExpression(what.arrayvar)
|
asmgen.out(" jsr prog8_lib.rol_array_uw")
|
||||||
asmgen.translateExpression(what.indexer)
|
|
||||||
asmgen.out(" jsr prog8_lib.rol_array_uw_cc")
|
|
||||||
}
|
}
|
||||||
is IdentifierReference -> {
|
is IdentifierReference -> {
|
||||||
val variable = asmgen.asmVariableName(what)
|
val variable = asmgen.asmVariableName(what)
|
||||||
@ -465,6 +440,24 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun translateRolRorMemoryArgs(addressExpression: Expression, fcall: IFunctionCall) {
|
||||||
|
val src = AsmAssignSource.fromAstSource(addressExpression, program, asmgen)
|
||||||
|
val tgt = AsmAssignTarget.fromRegisters(RegisterOrPair.AY, null, program, asmgen)
|
||||||
|
val assign = AsmAssignment(src, tgt, false, (fcall as Node).position)
|
||||||
|
asmgen.translateNormalAssignment(assign)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun translateRolRorArrayArgs(arrayvar: IdentifierReference, indexer: ArrayIndex, fcall: IFunctionCall, operation: String, dt: Char) {
|
||||||
|
var src = AsmAssignSource.fromAstSource(AddressOf(arrayvar, (fcall as Node).position), program, asmgen)
|
||||||
|
var tgt = AsmAssignTarget(TargetStorageKind.VARIABLE, program, asmgen, DataType.UWORD, null, variableAsmName = "prog8_lib.${operation}_array_u${dt}._arg_target")
|
||||||
|
var assign = AsmAssignment(src, tgt, false, (fcall as Node).position)
|
||||||
|
asmgen.translateNormalAssignment(assign)
|
||||||
|
src = AsmAssignSource.fromAstSource(indexer, program, asmgen)
|
||||||
|
tgt = AsmAssignTarget(TargetStorageKind.VARIABLE, program, asmgen, DataType.UBYTE, null, variableAsmName = "prog8_lib.${operation}_array_u${dt}._arg_index")
|
||||||
|
assign = AsmAssignment(src, tgt, false, (fcall as Node).position)
|
||||||
|
asmgen.translateNormalAssignment(assign)
|
||||||
|
}
|
||||||
|
|
||||||
private fun funcVariousFloatFuncs(fcall: IFunctionCall, func: FSignature, resultToStack: Boolean) {
|
private fun funcVariousFloatFuncs(fcall: IFunctionCall, func: FSignature, resultToStack: Boolean) {
|
||||||
translateArguments(fcall.args, func)
|
translateArguments(fcall.args, func)
|
||||||
if(resultToStack)
|
if(resultToStack)
|
||||||
@ -686,6 +679,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO find alternative way to swap here without using estack
|
||||||
asmgen.translateExpression(first)
|
asmgen.translateExpression(first)
|
||||||
asmgen.translateExpression(second)
|
asmgen.translateExpression(second)
|
||||||
val idatatype = first.inferType(program)
|
val idatatype = first.inferType(program)
|
||||||
|
@ -101,6 +101,14 @@ internal class AsmAssignSource(val kind: SourceStorageKind,
|
|||||||
asmgen.asmVariableName(array.arrayvar)
|
asmgen.asmVariableName(array.arrayvar)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
fun fromAstSource(indexer: ArrayIndex, program: Program, asmgen: AsmGen): AsmAssignSource {
|
||||||
|
return when {
|
||||||
|
indexer.indexNum!=null -> fromAstSource(indexer.indexNum!!, program, asmgen)
|
||||||
|
indexer.indexVar!=null -> fromAstSource(indexer.indexVar!!, program, asmgen)
|
||||||
|
else -> throw AssemblyError("weird indexer")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun fromAstSource(value: Expression, program: Program, asmgen: AsmGen): AsmAssignSource {
|
fun fromAstSource(value: Expression, program: Program, asmgen: AsmGen): AsmAssignSource {
|
||||||
val cv = value.constValue(program)
|
val cv = value.constValue(program)
|
||||||
if(cv!=null)
|
if(cv!=null)
|
||||||
|
@ -131,37 +131,41 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
|
|||||||
val preserveStatusRegisterAfterCall = sub.asmReturnvaluesRegisters.any { it.statusflag != null }
|
val preserveStatusRegisterAfterCall = sub.asmReturnvaluesRegisters.any { it.statusflag != null }
|
||||||
asmgen.translateFunctionCall(value, preserveStatusRegisterAfterCall)
|
asmgen.translateFunctionCall(value, preserveStatusRegisterAfterCall)
|
||||||
val returnValue = sub.returntypes.zip(sub.asmReturnvaluesRegisters).single { it.second.registerOrPair!=null }
|
val returnValue = sub.returntypes.zip(sub.asmReturnvaluesRegisters).single { it.second.registerOrPair!=null }
|
||||||
if(returnValue.first==DataType.STR) {
|
when (returnValue.first) {
|
||||||
when(assign.target.datatype) {
|
DataType.STR -> {
|
||||||
DataType.UWORD -> {
|
when(assign.target.datatype) {
|
||||||
// assign the address of the string result value
|
DataType.UWORD -> {
|
||||||
assignRegisterpairWord(assign.target, RegisterOrPair.AY)
|
// assign the address of the string result value
|
||||||
|
assignRegisterpairWord(assign.target, RegisterOrPair.AY)
|
||||||
|
}
|
||||||
|
DataType.STR, DataType.ARRAY_UB, DataType.ARRAY_B -> {
|
||||||
|
// copy the actual string result into the target string variable
|
||||||
|
asmgen.out("""
|
||||||
|
pha
|
||||||
|
lda #<${assign.target.asmVarname}
|
||||||
|
sta P8ZP_SCRATCH_W1
|
||||||
|
lda #>${assign.target.asmVarname}
|
||||||
|
sta P8ZP_SCRATCH_W1+1
|
||||||
|
pla
|
||||||
|
jsr prog8_lib.strcpy""")
|
||||||
|
}
|
||||||
|
else -> throw AssemblyError("weird target dt")
|
||||||
}
|
}
|
||||||
DataType.STR, DataType.ARRAY_UB, DataType.ARRAY_B -> {
|
|
||||||
// copy the actual string result into the target string variable
|
|
||||||
asmgen.out("""
|
|
||||||
pha
|
|
||||||
lda #<${assign.target.asmVarname}
|
|
||||||
sta P8ZP_SCRATCH_W1
|
|
||||||
lda #>${assign.target.asmVarname}
|
|
||||||
sta P8ZP_SCRATCH_W1+1
|
|
||||||
pla
|
|
||||||
jsr prog8_lib.strcpy""")
|
|
||||||
}
|
|
||||||
else -> throw AssemblyError("weird target dt")
|
|
||||||
}
|
}
|
||||||
} else if(returnValue.first==DataType.FLOAT) {
|
DataType.FLOAT -> {
|
||||||
// float result from function sits in FAC1
|
// float result from function sits in FAC1
|
||||||
assignFAC1float(assign.target)
|
assignFAC1float(assign.target)
|
||||||
} else {
|
}
|
||||||
when (returnValue.second.registerOrPair) {
|
else -> {
|
||||||
RegisterOrPair.A -> assignRegisterByte(assign.target, CpuRegister.A)
|
when (returnValue.second.registerOrPair) {
|
||||||
RegisterOrPair.X -> assignRegisterByte(assign.target, CpuRegister.X)
|
RegisterOrPair.A -> assignRegisterByte(assign.target, CpuRegister.A)
|
||||||
RegisterOrPair.Y -> assignRegisterByte(assign.target, CpuRegister.Y)
|
RegisterOrPair.X -> assignRegisterByte(assign.target, CpuRegister.X)
|
||||||
RegisterOrPair.AX -> assignRegisterpairWord(assign.target, RegisterOrPair.AX)
|
RegisterOrPair.Y -> assignRegisterByte(assign.target, CpuRegister.Y)
|
||||||
RegisterOrPair.AY -> assignRegisterpairWord(assign.target, RegisterOrPair.AY)
|
RegisterOrPair.AX -> assignRegisterpairWord(assign.target, RegisterOrPair.AX)
|
||||||
RegisterOrPair.XY -> assignRegisterpairWord(assign.target, RegisterOrPair.XY)
|
RegisterOrPair.AY -> assignRegisterpairWord(assign.target, RegisterOrPair.AY)
|
||||||
else -> throw AssemblyError("should be just one register byte result value")
|
RegisterOrPair.XY -> assignRegisterpairWord(assign.target, RegisterOrPair.XY)
|
||||||
|
else -> throw AssemblyError("should be just one register byte result value")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (preserveStatusRegisterAfterCall)
|
if (preserveStatusRegisterAfterCall)
|
||||||
|
@ -69,8 +69,7 @@ class FSignature(val name: String,
|
|||||||
actualParamTypes.isEmpty() -> CallConvention(emptyList(), returns)
|
actualParamTypes.isEmpty() -> CallConvention(emptyList(), returns)
|
||||||
actualParamTypes.size==1 -> {
|
actualParamTypes.size==1 -> {
|
||||||
// one parameter? via register/registerpair
|
// one parameter? via register/registerpair
|
||||||
val paramType = actualParamTypes[0]
|
val paramConv = when(val paramType = actualParamTypes[0]) {
|
||||||
val paramConv = when(paramType) {
|
|
||||||
DataType.UBYTE, DataType.BYTE -> ParamConvention(paramType, RegisterOrPair.A, false)
|
DataType.UBYTE, DataType.BYTE -> ParamConvention(paramType, RegisterOrPair.A, false)
|
||||||
DataType.UWORD, DataType.WORD -> ParamConvention(paramType, RegisterOrPair.AY, false)
|
DataType.UWORD, DataType.WORD -> ParamConvention(paramType, RegisterOrPair.AY, false)
|
||||||
DataType.FLOAT -> ParamConvention(paramType, RegisterOrPair.AY, false)
|
DataType.FLOAT -> ParamConvention(paramType, RegisterOrPair.AY, false)
|
||||||
|
339
examples/test.p8
339
examples/test.p8
@ -3,48 +3,270 @@
|
|||||||
%import syslib
|
%import syslib
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; builtin functions converted to new call convention:
|
|
||||||
;
|
|
||||||
; all functions operating on floating-point and fp arrays.
|
|
||||||
;
|
|
||||||
; mkword
|
|
||||||
; lsb
|
|
||||||
; msb
|
|
||||||
; swap
|
|
||||||
|
|
||||||
; abs
|
|
||||||
; sgn
|
|
||||||
; sqrt16
|
|
||||||
; rnd, rndw
|
|
||||||
; sin8, sin8u, cos8, cos8u
|
|
||||||
; sin16, sin16u, cos16, cos16u
|
|
||||||
; max, min
|
|
||||||
; any, all
|
|
||||||
; sum
|
|
||||||
; sort
|
|
||||||
; reverse
|
|
||||||
|
|
||||||
; exit
|
|
||||||
; read_flags
|
|
||||||
; memset, memsetw, memcopy
|
|
||||||
; leftstr, rightstr, substr
|
|
||||||
; strlen, strcmp
|
|
||||||
|
|
||||||
; TODO: in-place rols and rors
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
const uword ADDR = $0400
|
rotations()
|
||||||
const uword ADDR2 = $4000
|
strings()
|
||||||
|
integers()
|
||||||
|
floatingpoint()
|
||||||
|
|
||||||
; memset(ADDR2, 40*25, '*')
|
testX()
|
||||||
; memset(ADDR2, 40, '1')
|
}
|
||||||
; memset(ADDR2+24*40, 39, '2')
|
|
||||||
; memsetw(ADDR2, 40*25/2, $3132)
|
sub rotations() {
|
||||||
; memsetw(ADDR2, 20, $4142)
|
ubyte[] ubarr = [%11000111]
|
||||||
; memsetw(ADDR2+24*40, 19, $4241)
|
uword[] uwarr = [%1100111110101010]
|
||||||
; memcopy(ADDR2, ADDR, 200)
|
|
||||||
|
repeat(10) {
|
||||||
|
txt.chrout('\n')
|
||||||
|
}
|
||||||
|
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
uwarr[0] = %1100111110101010
|
||||||
|
ror(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
clear_carry()
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(uwarr[0])
|
||||||
|
txt.print_uwbin(uwarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
set_carry()
|
||||||
|
ror(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(ubarr[0])
|
||||||
|
txt.print_ubbin(ubarr[0], true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
&ubyte membyte = $c000
|
||||||
|
uword addr = $c000
|
||||||
|
|
||||||
|
@(addr) = %10110101
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
rol(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
@(addr) = %10110101
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
set_carry()
|
||||||
|
ror(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
@(addr) = %10110101
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
rol2(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
@(addr) = %10110101
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
ror2(@(addr))
|
||||||
|
txt.print_ubbin(@(addr), true)
|
||||||
|
txt.chrout('\n')
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
|
||||||
|
testX()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sub strings() {
|
||||||
|
const uword ADDR = $8400
|
||||||
|
const uword ADDR2 = $8000
|
||||||
|
|
||||||
|
memset(ADDR2, 40*25, '*')
|
||||||
|
memset(ADDR2, 40, '1')
|
||||||
|
memset(ADDR2+24*40, 39, '2')
|
||||||
|
memsetw(ADDR2, 40*25/2, $3132)
|
||||||
|
memsetw(ADDR2, 20, $4142)
|
||||||
|
memsetw(ADDR2+24*40, 19, $4241)
|
||||||
|
memcopy(ADDR2, ADDR, 200)
|
||||||
|
|
||||||
str result = "?" *10
|
str result = "?" *10
|
||||||
str s1 = "irmen"
|
str s1 = "irmen"
|
||||||
@ -609,47 +831,6 @@ main {
|
|||||||
floats.print_f(fl)
|
floats.print_f(fl)
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
|
|
||||||
; ub = min(barr)
|
|
||||||
;
|
|
||||||
; ub = zero+min(barr)*1+zero
|
|
||||||
; txt.print_ub(ub)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
;
|
|
||||||
; ub = max(barr)
|
|
||||||
; txt.print_ub(ub)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
;
|
|
||||||
; ub = zero+max(barr)*1+zero
|
|
||||||
; txt.print_ub(ub)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
;
|
|
||||||
; uw = sum(barr)
|
|
||||||
; txt.print_uw(uw)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
;
|
|
||||||
; uw = zero+sum(barr)*1+zero
|
|
||||||
; txt.print_uw(uw)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
;
|
|
||||||
; ub = any(barr)
|
|
||||||
; txt.print_ub(ub)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
;
|
|
||||||
; ub = zero+any(barr)*1
|
|
||||||
; txt.print_ub(ub)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
;
|
|
||||||
; ub = all(barr)
|
|
||||||
; txt.print_ub(ub)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
;
|
|
||||||
; ub = zero+all(barr)*1
|
|
||||||
; txt.print_ub(ub)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
testX()
|
testX()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user