incr decr fixes

This commit is contained in:
Irmen de Jong 2018-01-01 17:56:55 +01:00
parent aa2f3dd169
commit 57bc7d49bc
8 changed files with 296 additions and 585 deletions

View File

@ -164,6 +164,9 @@ class IntegerValue(Value):
def __str__(self):
return "<IntegerValue {} name={}>".format(self.value, self.name)
def negative(self) -> 'IntegerValue':
return IntegerValue(-self.value, self.sourceref, datatype=self.datatype, name=self.name)
class FloatValue(Value):
def __init__(self, value: float, sourceref: SourceRef, name: str = None) -> None:
@ -187,6 +190,9 @@ class FloatValue(Value):
def __str__(self):
return "<FloatValue {} name={}>".format(self.value, self.name)
def negative(self) -> 'FloatValue':
return FloatValue(-self.value, self.sourceref, name=self.name)
class StringValue(Value):
def __init__(self, value: str, sourceref: SourceRef, name: str = None, constant: bool = False) -> None:
@ -419,21 +425,21 @@ class ReturnStmt(_AstNode):
class InplaceIncrStmt(_AstNode):
def __init__(self, what: Value, howmuch: Union[None, int, float], byname: Optional[str], sourceref: SourceRef) -> None:
def __init__(self, what: Value, value: Union[IntegerValue, FloatValue], sourceref: SourceRef) -> None:
super().__init__(sourceref)
assert howmuch is None or howmuch > 0
assert value.constant
assert (value.value is None and value.name) or value.value > 0
self.what = what
self.howmuch = howmuch
self.float_var_name = byname
self.value = value
class InplaceDecrStmt(_AstNode):
def __init__(self, what: Value, howmuch: Union[None, int, float], byname: Optional[str], sourceref: SourceRef) -> None:
def __init__(self, what: Value, value: Union[IntegerValue, FloatValue], sourceref: SourceRef) -> None:
super().__init__(sourceref)
assert howmuch is None or howmuch > 0
assert value.constant
assert (value.value is None and value.name) or value.value > 0
self.what = what
self.howmuch = howmuch
self.float_var_name = byname
self.value = value
class IfCondition(_AstNode):

View File

@ -396,10 +396,13 @@ class CodeGenerator:
self.previous_stmt_was_assignment = isinstance(stmt, AssignmentStmt)
def generate_incr_or_decr(self, stmt: Union[InplaceIncrStmt, InplaceDecrStmt]) -> None:
assert (stmt.howmuch is None and stmt.float_var_name) or (stmt.howmuch > 0 and not stmt.float_var_name)
if stmt.what.datatype != DataType.FLOAT and stmt.howmuch > 0xff:
assert stmt.value.constant
assert (stmt.value.value is None and stmt.value.name) or stmt.value.value > 0
if stmt.what.datatype != DataType.FLOAT and not stmt.value.name and stmt.value.value > 0xff:
raise CodeError("only supports integer incr/decr by up to 255 for now") # XXX
is_incr = isinstance(stmt, InplaceIncrStmt)
howmuch = stmt.value.value
value_str = stmt.value.name or str(howmuch)
if isinstance(stmt.what, RegisterValue):
reg = stmt.what.register
# note: these operations below are all checked to be ok
@ -407,9 +410,9 @@ class CodeGenerator:
if reg == 'A':
# a += 1..255
self.p("\t\tclc")
self.p("\t\tadc #{:d}".format(stmt.howmuch))
self.p("\t\tadc #" + value_str)
elif reg in REGISTER_BYTES:
if stmt.howmuch == 1:
if howmuch == 1:
# x/y += 1
self.p("\t\tin{:s}".format(reg.lower()))
else:
@ -417,25 +420,25 @@ class CodeGenerator:
self.p("\t\tpha")
self.p("\t\tt{:s}a".format(reg.lower()))
self.p("\t\tclc")
self.p("\t\tadc #{:d}".format(stmt.howmuch))
self.p("\t\tadc #" + value_str)
self.p("\t\tta{:s}".format(reg.lower()))
self.p("\t\tpla")
elif reg == "AX":
# AX += 1..255
self.p("\t\tclc")
self.p("\t\tadc #{:d}".format(stmt.howmuch))
self.p("\t\tadc #" + value_str)
self.p("\t\tbcc +")
self.p("\t\tinx")
self.p("+")
elif reg == "AY":
# AY += 1..255
self.p("\t\tclc")
self.p("\t\tadc #{:d}".format(stmt.howmuch))
self.p("\t\tadc # " + value_str)
self.p("\t\tbcc +")
self.p("\t\tiny")
self.p("+")
elif reg == "XY":
if stmt.howmuch == 1:
if howmuch == 1:
# XY += 1
self.p("\t\tinx")
self.p("\t\tbne +")
@ -446,7 +449,7 @@ class CodeGenerator:
self.p("\t\tpha")
self.p("\t\ttxa")
self.p("\t\tclc")
self.p("\t\tadc #{:d}".format(stmt.howmuch))
self.p("\t\tadc #" + value_str)
self.p("\t\ttax")
self.p("\t\tbcc +")
self.p("\t\tiny")
@ -457,9 +460,9 @@ class CodeGenerator:
if reg == 'A':
# a -= 1..255
self.p("\t\tsec")
self.p("\t\tsbc #{:d}".format(stmt.howmuch))
self.p("\t\tsbc #" + value_str)
elif reg in REGISTER_BYTES:
if stmt.howmuch == 1:
if howmuch == 1:
# x/y -= 1
self.p("\t\tde{:s}".format(reg.lower()))
else:
@ -467,25 +470,25 @@ class CodeGenerator:
self.p("\t\tpha")
self.p("\t\tt{:s}a".format(reg.lower()))
self.p("\t\tsec")
self.p("\t\tsbc #{:d}".format(stmt.howmuch))
self.p("\t\tsbc #" + value_str)
self.p("\t\tta{:s}".format(reg.lower()))
self.p("\t\tpla")
elif reg == "AX":
# AX -= 1..255
self.p("\t\tsec")
self.p("\t\tsbc #{:d}".format(stmt.howmuch))
self.p("\t\tsbc #" + value_str)
self.p("\t\tbcs +")
self.p("\t\tdex")
self.p("+")
elif reg == "AY":
# AY -= 1..255
self.p("\t\tsec")
self.p("\t\tsbc #{:d}".format(stmt.howmuch))
self.p("\t\tsbc #" + value_str)
self.p("\t\tbcs +")
self.p("\t\tdey")
self.p("+")
elif reg == "XY":
if stmt.howmuch == 1:
if howmuch == 1:
# XY -= 1
self.p("\t\tcpx #0")
self.p("\t\tbne +")
@ -496,7 +499,7 @@ class CodeGenerator:
self.p("\t\tpha")
self.p("\t\ttxa")
self.p("\t\tsec")
self.p("\t\tsbc #{:d}".format(stmt.howmuch))
self.p("\t\tsbc #" + value_str)
self.p("\t\ttax")
self.p("\t\tbcs +")
self.p("\t\tdey")
@ -507,86 +510,86 @@ class CodeGenerator:
what = stmt.what
if isinstance(what, IndirectValue):
if isinstance(what.value, IntegerValue):
r_str = what.value.name or Parser.to_hex(what.value.value)
what_str = what.value.name or Parser.to_hex(what.value.value)
else:
raise CodeError("invalid incr indirect type", what.value)
else:
r_str = what.name or Parser.to_hex(what.address)
what_str = what.name or Parser.to_hex(what.address)
if what.datatype == DataType.BYTE:
if stmt.howmuch == 1:
self.p("\t\t{:s} {:s}".format("inc" if is_incr else "dec", r_str))
if howmuch == 1:
self.p("\t\t{:s} {:s}".format("inc" if is_incr else "dec", what_str))
else:
self.p("\t\tpha")
self.p("\t\tlda " + r_str)
self.p("\t\tlda " + what_str)
if is_incr:
self.p("\t\tclc")
self.p("\t\tadc #{:d}".format(stmt.howmuch))
self.p("\t\tadc #" + value_str)
else:
self.p("\t\tsec")
self.p("\t\tsbc #{:d}".format(stmt.howmuch))
self.p("\t\tsta " + r_str)
self.p("\t\tsbc #" + value_str)
self.p("\t\tsta " + what_str)
self.p("\t\tpla")
elif what.datatype == DataType.WORD:
if stmt.howmuch == 1:
if howmuch == 1:
# mem.word +=/-= 1
if is_incr:
self.p("\t\tinc " + r_str)
self.p("\t\tinc " + what_str)
self.p("\t\tbne +")
self.p("\t\tinc {:s}+1".format(r_str))
self.p("\t\tinc {:s}+1".format(what_str))
self.p("+")
else:
self.p("\t\tpha")
self.p("\t\tlda " + r_str)
self.p("\t\tlda " + what_str)
self.p("\t\tbne +")
self.p("\t\tdec {:s}+1".format(r_str))
self.p("+\t\tdec " + r_str)
self.p("\t\tdec {:s}+1".format(what_str))
self.p("+\t\tdec " + what_str)
self.p("\t\tpla")
else:
# mem.word +=/-= 2..255
if is_incr:
self.p("\t\tpha")
self.p("\t\tclc")
self.p("\t\tlda " + r_str)
self.p("\t\tadc #{:d}".format(stmt.howmuch))
self.p("\t\tsta " + r_str)
self.p("\t\tlda " + what_str)
self.p("\t\tadc #" + value_str)
self.p("\t\tsta " + what_str)
self.p("\t\tbcc +")
self.p("\t\tinc {:s}+1".format(r_str))
self.p("\t\tinc {:s}+1".format(what_str))
self.p("+\t\tpla")
else:
self.p("\t\tpha")
self.p("\t\tsec")
self.p("\t\tlda " + r_str)
self.p("\t\tsbc #{:d}".format(stmt.howmuch))
self.p("\t\tsta " + r_str)
self.p("\t\tlda " + what_str)
self.p("\t\tsbc #" + value_str)
self.p("\t\tsta " + what_str)
self.p("\t\tbcs +")
self.p("\t\tdec {:s}+1".format(r_str))
self.p("\t\tdec {:s}+1".format(what_str))
self.p("+\t\tpla")
elif what.datatype == DataType.FLOAT:
if stmt.howmuch == 1.0:
if howmuch == 1.0:
# special case for +/-1
with self.preserving_registers({'A', 'X', 'Y'}, loads_a_within=True):
self.p("\t\tldx #<" + r_str)
self.p("\t\tldy #>" + r_str)
self.p("\t\tldx #<" + what_str)
self.p("\t\tldy #>" + what_str)
if is_incr:
self.p("\t\tjsr il65_lib.float_add_one")
self.p("\t\tjsr c64flt.float_add_one")
else:
self.p("\t\tjsr il65_lib.float_sub_one")
elif stmt.float_var_name:
self.p("\t\tjsr c64flt.float_sub_one")
elif stmt.value.name:
with self.preserving_registers({'A', 'X', 'Y'}, loads_a_within=True):
self.p("\t\tlda #<" + stmt.float_var_name)
self.p("\t\tlda #<" + stmt.value.name)
self.p("\t\tsta c64.SCRATCH_ZPWORD1")
self.p("\t\tlda #>" + stmt.float_var_name)
self.p("\t\tlda #>" + stmt.value.name)
self.p("\t\tsta c64.SCRATCH_ZPWORD1+1")
self.p("\t\tldx #<" + r_str)
self.p("\t\tldy #>" + r_str)
self.p("\t\tldx #<" + what_str)
self.p("\t\tldy #>" + what_str)
if is_incr:
self.p("\t\tjsr il65_lib.float_add_SW1_to_XY")
self.p("\t\tjsr c64flt.float_add_SW1_to_XY")
else:
self.p("\t\tjsr il65_lib.float_sub_SW1_from_XY")
self.p("\t\tjsr c64flt.float_sub_SW1_from_XY")
else:
raise CodeError("incr/decr missing float constant definition")
else:
raise CodeError("cannot in/decrement memory of type " + str(what.datatype), stmt.howmuch)
raise CodeError("cannot in/decrement memory of type " + str(what.datatype), howmuch)
else:
raise CodeError("cannot in/decrement " + str(stmt.what))
@ -1536,7 +1539,7 @@ class CodeGenerator:
# assigning a register to a float requires c64 ROM routines
if r_register in REGISTER_WORDS:
def do_rom_calls():
self.p("\t\tjsr c64.GIVUAYF") # uword AY -> fac1
self.p("\t\tjsr c64flt.GIVUAYF") # uword AY -> fac1
self.p("\t\tldx #<" + lv_string)
self.p("\t\tldy #>" + lv_string)
self.p("\t\tjsr c64.FTOMEMXY") # fac1 -> memory XY
@ -1772,7 +1775,7 @@ class CodeGenerator:
self.p("\t\tsta c64.SCRATCH_ZPWORD1+1")
self.p("\t\tldx #<" + l_str)
self.p("\t\tldy #>" + l_str)
self.p("\t\tjsr il65_lib.copy_mflt")
self.p("\t\tjsr c64flt.copy_mflt")
elif rvalue.datatype == DataType.BYTE:
with self.preserving_registers({'A', 'X', 'Y'}):
self.p("\t\tldy " + r_str)
@ -1784,7 +1787,7 @@ class CodeGenerator:
with self.preserving_registers({'A', 'X', 'Y'}, loads_a_within=True):
self.p("\t\tlda " + r_str)
self.p("\t\tldy {:s}+1".format(r_str))
self.p("\t\tjsr c64.GIVUAYF") # uword AY -> fac1
self.p("\t\tjsr c64flt.GIVUAYF") # uword AY -> fac1
self.p("\t\tldx #<" + l_str)
self.p("\t\tldy #>" + l_str)
self.p("\t\tjsr c64.FTOMEMXY") # fac1 -> memory XY

View File

@ -254,10 +254,11 @@ class Parser:
def desugar_immediate_floats(stmt: _AstNode, containing_block: Block) -> None:
if isinstance(stmt, (InplaceIncrStmt, InplaceDecrStmt)):
if stmt.howmuch is None:
assert stmt.float_var_name
howmuch = stmt.value.value
if howmuch is None:
assert stmt.value.name
return
if stmt.howmuch in (0, 1):
if howmuch in (0, 1) or type(howmuch) is int:
return # 1 is special cased in the code generator
rom_floats = {
1: "c64.FL_FONE",
@ -276,24 +277,24 @@ class Parser:
1.0 / math.log(2): "c64.FL_LOGEB2",
}
for fv, name in rom_floats.items():
if math.isclose(stmt.howmuch, fv, rel_tol=0, abs_tol=1e-9):
if math.isclose(howmuch, fv, rel_tol=0, abs_tol=1e-9):
# use one of the constants available in ROM
stmt.float_var_name = name
stmt.value.name = name
return
if stmt.howmuch in self._immediate_floats:
if howmuch in self._immediate_floats:
# reuse previously defined float constant
blockname, floatvar_name = self._immediate_floats[stmt.howmuch]
blockname, floatvar_name = self._immediate_floats[howmuch]
if blockname:
stmt.float_var_name = blockname + '.' + floatvar_name
stmt.value.name = blockname + '.' + floatvar_name
else:
stmt.float_var_name = floatvar_name
stmt.value.name = floatvar_name
else:
# define new float variable to hold the incr/decr value
# note: not a constant, because we need the MFLT bytes
floatvar_name = "il65_float_{:d}".format(id(stmt))
containing_block.symbols.define_variable(floatvar_name, stmt.sourceref, DataType.FLOAT, value=stmt.howmuch)
self._immediate_floats[stmt.howmuch] = (containing_block.name, floatvar_name)
stmt.float_var_name = floatvar_name
containing_block.symbols.define_variable(floatvar_name, stmt.sourceref, DataType.FLOAT, value=howmuch)
self._immediate_floats[howmuch] = (containing_block.name, floatvar_name)
stmt.value.name = floatvar_name
for block in self.result.blocks:
self.cur_block = block
@ -826,9 +827,10 @@ class Parser:
what = self.parse_expression(line[:-2].rstrip())
if isinstance(what, IntegerValue):
raise self.PError("cannot in/decrement a constant value")
one_value = IntegerValue(1, self.sourceref)
if incr:
return InplaceIncrStmt(what, 1, None, self.sourceref)
return InplaceDecrStmt(what, 1, None, self.sourceref)
return InplaceIncrStmt(what, one_value, self.sourceref)
return InplaceDecrStmt(what, one_value, self.sourceref)
else:
# perhaps it is an augmented assignment statement
match = re.fullmatch(r"(?P<left>\S+)\s*(?P<assignment>\+=|-=|\*=|/=|%=|//=|\*\*=|&=|\|=|\^=|>>=|<<=)\s*(?P<right>\S.*)", line)
@ -967,27 +969,24 @@ class Parser:
if truncated:
r_value = IntegerValue(int(value), self.sourceref, datatype=l_value.datatype, name=r_value.name)
if operator in ("+=", "-="):
# see if we can simplify this to inplace incr/decr statement
# see if we can simplify this to inplace incr/decr statement (only int/float constant values)
if r_value.constant:
if not isinstance(r_value, (IntegerValue, FloatValue)):
raise self.PError("incr/decr requires constant int or float, not " + r_value.__class__.__name__)
if operator == "+=":
if r_value.value > 0: # type: ignore
return InplaceIncrStmt(l_value, r_value.value, None, self.sourceref)
elif r_value.value < 0: # type: ignore
return InplaceDecrStmt(l_value, -r_value.value, None, self.sourceref)
if r_value.value > 0:
return InplaceIncrStmt(l_value, r_value, self.sourceref)
elif r_value.value < 0:
return InplaceDecrStmt(l_value, r_value.negative(), self.sourceref)
else:
self.print_warning("incr with zero, ignored")
else:
if r_value.value > 0: # type: ignore
return InplaceDecrStmt(l_value, r_value.value, None, self.sourceref)
elif r_value.value < 0: # type: ignore
return InplaceIncrStmt(l_value, -r_value.value, None, self.sourceref)
if r_value.value > 0:
return InplaceDecrStmt(l_value, r_value, self.sourceref)
elif r_value.value < 0:
return InplaceIncrStmt(l_value, r_value.negative(), self.sourceref)
else:
self.print_warning("decr with zero, ignored")
else:
if r_value.name:
if operator == "+=":
return InplaceIncrStmt(l_value, None, r_value.name, self.sourceref)
return InplaceDecrStmt(l_value, None, r_value.name, self.sourceref)
return AugmentedAssignmentStmt(l_value, operator, r_value, self.sourceref)
def parse_return(self, line: str) -> ReturnStmt:
@ -1404,7 +1403,9 @@ class Optimizer:
# some symbols are used by the emitted assembly code from the code generator,
# and should never be removed or the assembler will fail
# @todo make this dynamic
never_remove = {"c64.GIVUAYF", "c64.FREADUY", "c64.FTOMEMXY", "c64.FADD", "c64.FSUB"}
never_remove = {"c64.FREADUY", "c64.FTOMEMXY", "c64.FADD", "c64.FSUB",
"c64flt.GIVUAYF", "c64flt.copy_mflt", "c64flt.float_add_one", "c64flt.float_sub_one",
"c64flt.float_add_SW1_to_XY", "c64flt.float_sub_SW1_from_XY"}
discarded = []
for sub in list(block.symbols.iter_subroutines()):
usages = self.parsed.subroutine_usage[(sub.blockname, sub.name)]

View File

@ -115,17 +115,17 @@ sub MOVAF () -> (A?, X?) = $bc0c ; copy fac1 to fac2 (rounded)
sub MOVEF () -> (A?, X?) = $bc0f ; copy fac1 to fac2
sub FTOMEMXY (mflpt: XY) -> (A?, Y?) = $bbd4 ; store fac1 to memory X/Y as 5-byte mflpt
sub FTOSWORDYA () -> (Y, A, X?) = $b1aa ; fac1-> signed word in Y/A (might throw ILLEGAL QUANTITY)
; use c64.FTOSWRDAY to get A/Y output (lo/hi switched to normal order)
; use c64flt.FTOSWRDAY to get A/Y output (lo/hi switched to normal order)
sub GETADR () -> (Y, A, X?) = $b7f7 ; fac1 -> unsigned word in Y/A (might throw ILLEGAL QUANTITY)
; (result also in $14/15) use c64.GETADRAY to get A/Y output (lo/hi switched to normal order)
; (result also in $14/15) use c64flt.GETADRAY to get A/Y output (lo/hi switched to normal order)
sub QINT () -> (?) = $bc9b ; fac1 -> 4-byte signed integer in 98-101 ($62-$65), with the MSB FIRST.
sub AYINT () -> (?) = $b1bf ; fac1-> signed word in 100-101 ($64-$65) MSB FIRST. (might throw ILLEGAL QUANTITY)
sub GIVAYF (lo: Y, hi: A) -> (?) = $b391 ; signed word in Y/A -> float in fac1
; use c64.GIVAYFAY to use A/Y input (lo/hi switched to normal order)
; there is also c64.GIVUAYF - unsigned word in A/Y (lo/hi) to fac1
; there is also c64.FREADS32 that reads from 98-101 ($62-$65) MSB FIRST
; there is also c64.FREADUS32 that reads from 98-101 ($62-$65) MSB FIRST
; there is also c64.FREADS24AXY that reads signed int24 into fac1 from A/X/Y (lo/mid/hi bytes)
; use c64flt.GIVAYFAY to use A/Y input (lo/hi switched to normal order)
; there is also c64flt.GIVUAYF - unsigned word in A/Y (lo/hi) to fac1
; there is also c64flt.FREADS32 that reads from 98-101 ($62-$65) MSB FIRST
; there is also c64flt.FREADUS32 that reads from 98-101 ($62-$65) MSB FIRST
; there is also c64flt.FREADS24AXY that reads signed int24 into fac1 from A/X/Y (lo/mid/hi bytes)
sub FREADUY (ubyte: Y) -> (?) = $b3a2 ; 8 bit unsigned Y -> float in fac1
sub FREADSA (sbyte: A) -> (?) = $bc3c ; 8 bit signed A -> float in fac1
sub FREADSTR (len: A) -> (?) = $b7b5 ; str -> fac1, $22/23 must point to string, A=string length
@ -259,6 +259,14 @@ sub init_system () -> (?) {
}
}
} ; ------ end of block c64
~ c64flt {
; ---- this block contains C-64 floating point related functions ----
sub FREADS32 () -> (?) {
; ---- fac1 = signed int32 from $62-$65 big endian (MSB FIRST)
asm {
@ -342,7 +350,99 @@ sub GETADRAY () -> (AY, X?) {
}
} ; ------ end of block c64
sub copy_mflt (source: XY) -> (A?, Y?) {
; ---- copy a 5 byte MFLT floating point variable to another place
; input: X/Y = source address, c64.SCRATCH_ZPWORD1 = destination address
asm {
stx c64.SCRATCH_ZP1
sty c64.SCRATCH_ZPWORD1+1
ldy #0
lda (c64.SCRATCH_ZP1),y
sta (c64.SCRATCH_ZPWORD1),y
iny
lda (c64.SCRATCH_ZP1),y
sta (c64.SCRATCH_ZPWORD1),y
iny
lda (c64.SCRATCH_ZP1),y
sta (c64.SCRATCH_ZPWORD1),y
iny
lda (c64.SCRATCH_ZP1),y
sta (c64.SCRATCH_ZPWORD1),y
iny
lda (c64.SCRATCH_ZP1),y
sta (c64.SCRATCH_ZPWORD1),y
ldy c64.SCRATCH_ZPWORD1+1
rts
}
}
sub float_add_one (mflt: XY) -> (?) {
; ---- add 1 to the MFLT pointed to by X/Y. Clobbers A, X, Y
asm {
stx c64.SCRATCH_ZP1
sty c64.SCRATCH_ZP2
txa
jsr c64.MOVFM ; fac1 = float XY
lda #<c64.FL_FONE
ldy #>c64.FL_FONE
jsr c64.FADD ; fac1 += 1
ldx c64.SCRATCH_ZP1
ldy c64.SCRATCH_ZP2
jmp c64.FTOMEMXY ; float XY = fac1
}
}
sub float_sub_one (mflt: XY) -> (?) {
; ---- subtract 1 from the MFLT pointed to by X/Y. Clobbers A, X, Y
asm {
stx c64.SCRATCH_ZP1
sty c64.SCRATCH_ZP2
lda #<c64.FL_FONE
ldy #>c64.FL_FONE
jsr c64.MOVFM ; fac1 = 1
txa
ldy c64.SCRATCH_ZP2
jsr c64.FSUB ; fac1 = float XY - 1
ldx c64.SCRATCH_ZP1
ldy c64.SCRATCH_ZP2
jmp c64.FTOMEMXY ; float XY = fac1
}
}
sub float_add_SW1_to_XY (mflt: XY) -> (?) {
; ---- add MFLT pointed to by SCRATCH_ZPWORD1 to the MFLT pointed to by X/Y. Clobbers A, X, Y
asm {
stx c64.SCRATCH_ZP1
sty c64.SCRATCH_ZP2
txa
jsr c64.MOVFM ; fac1 = float XY
lda c64.SCRATCH_ZPWORD1
ldy c64.SCRATCH_ZPWORD1+1
jsr c64.FADD ; fac1 += SCRATCH_ZPWORD1
ldx c64.SCRATCH_ZP1
ldy c64.SCRATCH_ZP2
jmp c64.FTOMEMXY ; float XY = fac1
}
}
sub float_sub_SW1_from_XY (mflt: XY) -> (?) {
; ---- subtract MFLT pointed to by SCRATCH_ZPWORD1 from the MFLT pointed to by X/Y. Clobbers A, X, Y
asm {
stx c64.SCRATCH_ZP1
sty c64.SCRATCH_ZP2
lda c64.SCRATCH_ZPWORD1
ldy c64.SCRATCH_ZPWORD1+1
jsr c64.MOVFM ; fac1 = SCRATCH_ZPWORD1
txa
ldy c64.SCRATCH_ZP2
jsr c64.FSUB ; fac1 = float XY - SCRATCH_ZPWORD1
ldx c64.SCRATCH_ZP1
ldy c64.SCRATCH_ZP2
jmp c64.FTOMEMXY ; float XY = fac1
}
}
} ; ------ end of block c64flt
@ -391,32 +491,10 @@ sub scroll_left_full (alsocolors: SC) -> (A?, X?, Y?) {
ldx #0
ldy #38
-
lda c64.Colors + 40*0 + 1,x
sta c64.Colors + 40*0,x
lda c64.Colors + 40*1 + 1,x
sta c64.Colors + 40*1,x
lda c64.Colors + 40*2 + 1,x
sta c64.Colors + 40*2,x
lda c64.Colors + 40*3 + 1,x
sta c64.Colors + 40*3,x
lda c64.Colors + 40*4 + 1,x
sta c64.Colors + 40*4,x
lda c64.Colors + 40*5 + 1,x
sta c64.Colors + 40*5,x
lda c64.Colors + 40*6 + 1,x
sta c64.Colors + 40*6,x
lda c64.Colors + 40*7 + 1,x
sta c64.Colors + 40*7,x
lda c64.Colors + 40*8 + 1,x
sta c64.Colors + 40*8,x
lda c64.Colors + 40*9 + 1,x
sta c64.Colors + 40*9,x
lda c64.Colors + 40*10 + 1,x
sta c64.Colors + 40*10,x
lda c64.Colors + 40*11 + 1,x
sta c64.Colors + 40*11,x
lda c64.Colors + 40*12 + 1,x
sta c64.Colors + 40*12,x
.for row=0, row<=12, row+=1
lda c64.Colors + 40*row + 1,x
sta c64.Colors + 40*row,x
.next
inx
dey
bpl -
@ -424,30 +502,10 @@ sub scroll_left_full (alsocolors: SC) -> (A?, X?, Y?) {
ldx #0
ldy #38
-
lda c64.Colors + 40*13 + 1,x
sta c64.Colors + 40*13,x
lda c64.Colors + 40*14 + 1,x
sta c64.Colors + 40*14,x
lda c64.Colors + 40*15 + 1,x
sta c64.Colors + 40*15,x
lda c64.Colors + 40*16 + 1,x
sta c64.Colors + 40*16,x
lda c64.Colors + 40*17 + 1,x
sta c64.Colors + 40*17,x
lda c64.Colors + 40*18 + 1,x
sta c64.Colors + 40*18,x
lda c64.Colors + 40*19 + 1,x
sta c64.Colors + 40*19,x
lda c64.Colors + 40*20 + 1,x
sta c64.Colors + 40*20,x
lda c64.Colors + 40*21 + 1,x
sta c64.Colors + 40*21,x
lda c64.Colors + 40*22 + 1,x
sta c64.Colors + 40*22,x
lda c64.Colors + 40*23 + 1,x
sta c64.Colors + 40*23,x
lda c64.Colors + 40*24 + 1,x
sta c64.Colors + 40*24,x
.for row=13, row<=24, row+=1
lda c64.Colors + 40*row + 1,x
sta c64.Colors + 40*row,x
.next
inx
dey
bpl -
@ -456,32 +514,10 @@ _scroll_screen
ldx #0
ldy #38
-
lda c64.Screen + 40*0 + 1,x
sta c64.Screen + 40*0,x
lda c64.Screen + 40*1 + 1,x
sta c64.Screen + 40*1,x
lda c64.Screen + 40*2 + 1,x
sta c64.Screen + 40*2,x
lda c64.Screen + 40*3 + 1,x
sta c64.Screen + 40*3,x
lda c64.Screen + 40*4 + 1,x
sta c64.Screen + 40*4,x
lda c64.Screen + 40*5 + 1,x
sta c64.Screen + 40*5,x
lda c64.Screen + 40*6 + 1,x
sta c64.Screen + 40*6,x
lda c64.Screen + 40*7 + 1,x
sta c64.Screen + 40*7,x
lda c64.Screen + 40*8 + 1,x
sta c64.Screen + 40*8,x
lda c64.Screen + 40*9 + 1,x
sta c64.Screen + 40*9,x
lda c64.Screen + 40*10 + 1,x
sta c64.Screen + 40*10,x
lda c64.Screen + 40*11 + 1,x
sta c64.Screen + 40*11,x
lda c64.Screen + 40*12 + 1,x
sta c64.Screen + 40*12,x
.for row=0, row<=12, row+=1
lda c64.Screen + 40*row + 1,x
sta c64.Screen + 40*row,x
.next
inx
dey
bpl -
@ -489,33 +525,14 @@ _scroll_screen
ldx #0
ldy #38
-
lda c64.Screen + 40*13 + 1,x
sta c64.Screen + 40*13,x
lda c64.Screen + 40*14 + 1,x
sta c64.Screen + 40*14,x
lda c64.Screen + 40*15 + 1,x
sta c64.Screen + 40*15,x
lda c64.Screen + 40*16 + 1,x
sta c64.Screen + 40*16,x
lda c64.Screen + 40*17 + 1,x
sta c64.Screen + 40*17,x
lda c64.Screen + 40*18 + 1,x
sta c64.Screen + 40*18,x
lda c64.Screen + 40*19 + 1,x
sta c64.Screen + 40*19,x
lda c64.Screen + 40*20 + 1,x
sta c64.Screen + 40*20,x
lda c64.Screen + 40*21 + 1,x
sta c64.Screen + 40*21,x
lda c64.Screen + 40*22 + 1,x
sta c64.Screen + 40*22,x
lda c64.Screen + 40*23 + 1,x
sta c64.Screen + 40*23,x
lda c64.Screen + 40*24 + 1,x
sta c64.Screen + 40*24,x
.for row=13, row<=24, row+=1
lda c64.Screen + 40*row + 1,x
sta c64.Screen + 40*row,x
.next
inx
dey
bpl -
rts
}
}
@ -532,124 +549,41 @@ sub scroll_right_full (alsocolors: SC) -> (A?, X?) {
+
ldx #38
-
lda c64.Colors + 40*0,x
sta c64.Colors + 40*0 + 1,x
lda c64.Colors + 40*1,x
sta c64.Colors + 40*1 + 1,x
lda c64.Colors + 40*2,x
sta c64.Colors + 40*2 + 1,x
lda c64.Colors + 40*3,x
sta c64.Colors + 40*3 + 1,x
lda c64.Colors + 40*4,x
sta c64.Colors + 40*4 + 1,x
lda c64.Colors + 40*5,x
sta c64.Colors + 40*5 + 1,x
lda c64.Colors + 40*6,x
sta c64.Colors + 40*6 + 1,x
lda c64.Colors + 40*7,x
sta c64.Colors + 40*7 + 1,x
lda c64.Colors + 40*8,x
sta c64.Colors + 40*8 + 1,x
lda c64.Colors + 40*9,x
sta c64.Colors + 40*9 + 1,x
lda c64.Colors + 40*10,x
sta c64.Colors + 40*10 + 1,x
lda c64.Colors + 40*11,x
sta c64.Colors + 40*11 + 1,x
lda c64.Colors + 40*12,x
sta c64.Colors + 40*12 + 1,x
.for row=0, row<=12, row+=1
lda c64.Colors + 40*row + 0,x
sta c64.Colors + 40*row + 1,x
.next
dex
bpl -
ldx #38
-
lda c64.Colors + 40*13,x
sta c64.Colors + 40*13 + 1,x
lda c64.Colors + 40*14,x
sta c64.Colors + 40*14 + 1,x
lda c64.Colors + 40*15,x
sta c64.Colors + 40*15 + 1,x
lda c64.Colors + 40*16,x
sta c64.Colors + 40*16 + 1,x
lda c64.Colors + 40*17,x
sta c64.Colors + 40*17 + 1,x
lda c64.Colors + 40*18,x
sta c64.Colors + 40*18 + 1,x
lda c64.Colors + 40*19,x
sta c64.Colors + 40*19 + 1,x
lda c64.Colors + 40*20,x
sta c64.Colors + 40*20 + 1,x
lda c64.Colors + 40*21,x
sta c64.Colors + 40*21 + 1,x
lda c64.Colors + 40*22,x
sta c64.Colors + 40*22 + 1,x
lda c64.Colors + 40*23,x
sta c64.Colors + 40*23 + 1,x
lda c64.Colors + 40*24,x
sta c64.Colors + 40*24 + 1,x
.for row=13, row<=24, row+=1
lda c64.Colors + 40*row,x
sta c64.Colors + 40*row + 1,x
.next
dex
bpl -
_scroll_screen
ldx #38
-
lda c64.Screen + 40*0,x
sta c64.Screen + 40*0 + 1,x
lda c64.Screen + 40*1,x
sta c64.Screen + 40*1 + 1,x
lda c64.Screen + 40*2,x
sta c64.Screen + 40*2 + 1,x
lda c64.Screen + 40*3,x
sta c64.Screen + 40*3 + 1,x
lda c64.Screen + 40*4,x
sta c64.Screen + 40*4 + 1,x
lda c64.Screen + 40*5,x
sta c64.Screen + 40*5 + 1,x
lda c64.Screen + 40*6,x
sta c64.Screen + 40*6 + 1,x
lda c64.Screen + 40*7,x
sta c64.Screen + 40*7 + 1,x
lda c64.Screen + 40*8,x
sta c64.Screen + 40*8 + 1,x
lda c64.Screen + 40*9,x
sta c64.Screen + 40*9 + 1,x
lda c64.Screen + 40*10,x
sta c64.Screen + 40*10 + 1,x
lda c64.Screen + 40*11,x
sta c64.Screen + 40*11 + 1,x
lda c64.Screen + 40*12,x
sta c64.Screen + 40*12 + 1,x
.for row=0, row<=12, row+=1
lda c64.Screen + 40*row + 0,x
sta c64.Screen + 40*row + 1,x
.next
dex
bpl -
ldx #38
-
lda c64.Screen + 40*13,x
sta c64.Screen + 40*13 + 1,x
lda c64.Screen + 40*14,x
sta c64.Screen + 40*14 + 1,x
lda c64.Screen + 40*15,x
sta c64.Screen + 40*15 + 1,x
lda c64.Screen + 40*16,x
sta c64.Screen + 40*16 + 1,x
lda c64.Screen + 40*17,x
sta c64.Screen + 40*17 + 1,x
lda c64.Screen + 40*18,x
sta c64.Screen + 40*18 + 1,x
lda c64.Screen + 40*19,x
sta c64.Screen + 40*19 + 1,x
lda c64.Screen + 40*20,x
sta c64.Screen + 40*20 + 1,x
lda c64.Screen + 40*21,x
sta c64.Screen + 40*21 + 1,x
lda c64.Screen + 40*22,x
sta c64.Screen + 40*22 + 1,x
lda c64.Screen + 40*23,x
sta c64.Screen + 40*23 + 1,x
lda c64.Screen + 40*24,x
sta c64.Screen + 40*24 + 1,x
.for row=13, row<=24, row+=1
lda c64.Screen + 40*row,x
sta c64.Screen + 40*row + 1,x
.next
dex
bpl -
rts
}
}
@ -666,118 +600,38 @@ sub scroll_up_full (alsocolors: SC) -> (A?, X?) {
+
ldx #39
-
lda c64.Colors + 40*1,x
sta c64.Colors + 40*0,x
lda c64.Colors + 40*2,x
sta c64.Colors + 40*1,x
lda c64.Colors + 40*3,x
sta c64.Colors + 40*2,x
lda c64.Colors + 40*4,x
sta c64.Colors + 40*3,x
lda c64.Colors + 40*5,x
sta c64.Colors + 40*4,x
lda c64.Colors + 40*6,x
sta c64.Colors + 40*5,x
lda c64.Colors + 40*7,x
sta c64.Colors + 40*6,x
lda c64.Colors + 40*8,x
sta c64.Colors + 40*7,x
lda c64.Colors + 40*9,x
sta c64.Colors + 40*8,x
lda c64.Colors + 40*10,x
sta c64.Colors + 40*9,x
lda c64.Colors + 40*11,x
sta c64.Colors + 40*10,x
lda c64.Colors + 40*12,x
sta c64.Colors + 40*11,x
.for row=1, row<=11, row+=1
lda c64.Colors + 40*row,x
sta c64.Colors + 40*(row-1),x
.next
dex
bpl -
ldx #39
-
lda c64.Colors + 40*13,x
sta c64.Colors + 40*12,x
lda c64.Colors + 40*14,x
sta c64.Colors + 40*13,x
lda c64.Colors + 40*15,x
sta c64.Colors + 40*14,x
lda c64.Colors + 40*16,x
sta c64.Colors + 40*15,x
lda c64.Colors + 40*17,x
sta c64.Colors + 40*16,x
lda c64.Colors + 40*18,x
sta c64.Colors + 40*17,x
lda c64.Colors + 40*19,x
sta c64.Colors + 40*18,x
lda c64.Colors + 40*20,x
sta c64.Colors + 40*19,x
lda c64.Colors + 40*21,x
sta c64.Colors + 40*20,x
lda c64.Colors + 40*22,x
sta c64.Colors + 40*21,x
lda c64.Colors + 40*23,x
sta c64.Colors + 40*22,x
lda c64.Colors + 40*24,x
sta c64.Colors + 40*23,x
.for row=12, row<=24, row+=1
lda c64.Colors + 40*row,x
sta c64.Colors + 40*(row-1),x
.next
dex
bpl -
_scroll_screen
ldx #39
-
lda c64.Screen + 40*1,x
sta c64.Screen + 40*0,x
lda c64.Screen + 40*2,x
sta c64.Screen + 40*1,x
lda c64.Screen + 40*3,x
sta c64.Screen + 40*2,x
lda c64.Screen + 40*4,x
sta c64.Screen + 40*3,x
lda c64.Screen + 40*5,x
sta c64.Screen + 40*4,x
lda c64.Screen + 40*6,x
sta c64.Screen + 40*5,x
lda c64.Screen + 40*7,x
sta c64.Screen + 40*6,x
lda c64.Screen + 40*8,x
sta c64.Screen + 40*7,x
lda c64.Screen + 40*9,x
sta c64.Screen + 40*8,x
lda c64.Screen + 40*10,x
sta c64.Screen + 40*9,x
lda c64.Screen + 40*11,x
sta c64.Screen + 40*10,x
lda c64.Screen + 40*12,x
sta c64.Screen + 40*11,x
.for row=1, row<=11, row+=1
lda c64.Screen + 40*row,x
sta c64.Screen + 40*(row-1),x
.next
dex
bpl -
ldx #39
-
lda c64.Screen + 40*13,x
sta c64.Screen + 40*12,x
lda c64.Screen + 40*14,x
sta c64.Screen + 40*13,x
lda c64.Screen + 40*15,x
sta c64.Screen + 40*14,x
lda c64.Screen + 40*16,x
sta c64.Screen + 40*15,x
lda c64.Screen + 40*17,x
sta c64.Screen + 40*16,x
lda c64.Screen + 40*18,x
sta c64.Screen + 40*17,x
lda c64.Screen + 40*19,x
sta c64.Screen + 40*18,x
lda c64.Screen + 40*20,x
sta c64.Screen + 40*19,x
lda c64.Screen + 40*21,x
sta c64.Screen + 40*20,x
lda c64.Screen + 40*22,x
sta c64.Screen + 40*21,x
lda c64.Screen + 40*23,x
sta c64.Screen + 40*22,x
lda c64.Screen + 40*24,x
sta c64.Screen + 40*23,x
.for row=12, row<=24, row+=1
lda c64.Screen + 40*row,x
sta c64.Screen + 40*(row-1),x
.next
dex
bpl -
@ -797,122 +651,38 @@ sub scroll_down_full (alsocolors: SC) -> (A?, X?) {
+
ldx #39
-
lda c64.Colors + 40*23,x
sta c64.Colors + 40*24,x
lda c64.Colors + 40*22,x
sta c64.Colors + 40*23,x
lda c64.Colors + 40*21,x
sta c64.Colors + 40*22,x
lda c64.Colors + 40*20,x
sta c64.Colors + 40*21,x
lda c64.Colors + 40*19,x
sta c64.Colors + 40*20,x
lda c64.Colors + 40*18,x
sta c64.Colors + 40*19,x
lda c64.Colors + 40*17,x
sta c64.Colors + 40*18,x
lda c64.Colors + 40*16,x
sta c64.Colors + 40*17,x
lda c64.Colors + 40*15,x
sta c64.Colors + 40*16,x
lda c64.Colors + 40*14,x
sta c64.Colors + 40*15,x
lda c64.Colors + 40*13,x
sta c64.Colors + 40*14,x
lda c64.Colors + 40*12,x
sta c64.Colors + 40*13,x
.for row=23, row>=12, row-=1
lda c64.Colors + 40*row,x
sta c64.Colors + 40*(row+1),x
.next
dex
bpl -
ldx #39
-
lda c64.Colors + 40*11,x
sta c64.Colors + 40*12,x
lda c64.Colors + 40*10,x
sta c64.Colors + 40*11,x
lda c64.Colors + 40*9,x
sta c64.Colors + 40*10,x
lda c64.Colors + 40*8,x
sta c64.Colors + 40*9,x
lda c64.Colors + 40*7,x
sta c64.Colors + 40*8,x
lda c64.Colors + 40*6,x
sta c64.Colors + 40*7,x
lda c64.Colors + 40*5,x
sta c64.Colors + 40*6,x
lda c64.Colors + 40*4,x
sta c64.Colors + 40*5,x
lda c64.Colors + 40*3,x
sta c64.Colors + 40*4,x
lda c64.Colors + 40*2,x
sta c64.Colors + 40*3,x
lda c64.Colors + 40*1,x
sta c64.Colors + 40*2,x
lda c64.Colors + 40*0,x
sta c64.Colors + 40*1,x
.for row=11, row>=0, row-=1
lda c64.Colors + 40*row,x
sta c64.Colors + 40*(row+1),x
.next
dex
bpl -
_scroll_screen
ldx #39
-
lda c64.Screen + 40*23,x
sta c64.Screen + 40*24,x
lda c64.Screen + 40*22,x
sta c64.Screen + 40*23,x
lda c64.Screen + 40*21,x
sta c64.Screen + 40*22,x
lda c64.Screen + 40*20,x
sta c64.Screen + 40*21,x
lda c64.Screen + 40*19,x
sta c64.Screen + 40*20,x
lda c64.Screen + 40*18,x
sta c64.Screen + 40*19,x
lda c64.Screen + 40*17,x
sta c64.Screen + 40*18,x
lda c64.Screen + 40*16,x
sta c64.Screen + 40*17,x
lda c64.Screen + 40*15,x
sta c64.Screen + 40*16,x
lda c64.Screen + 40*14,x
sta c64.Screen + 40*15,x
lda c64.Screen + 40*13,x
sta c64.Screen + 40*14,x
lda c64.Screen + 40*12,x
sta c64.Screen + 40*13,x
.for row=23, row>=12, row-=1
lda c64.Screen + 40*row,x
sta c64.Screen + 40*(row+1),x
.next
dex
bpl -
ldx #39
-
lda c64.Screen + 40*11,x
sta c64.Screen + 40*12,x
lda c64.Screen + 40*10,x
sta c64.Screen + 40*11,x
lda c64.Screen + 40*9,x
sta c64.Screen + 40*10,x
lda c64.Screen + 40*8,x
sta c64.Screen + 40*9,x
lda c64.Screen + 40*7,x
sta c64.Screen + 40*8,x
lda c64.Screen + 40*6,x
sta c64.Screen + 40*7,x
lda c64.Screen + 40*5,x
sta c64.Screen + 40*6,x
lda c64.Screen + 40*4,x
sta c64.Screen + 40*5,x
lda c64.Screen + 40*3,x
sta c64.Screen + 40*4,x
lda c64.Screen + 40*2,x
sta c64.Screen + 40*3,x
lda c64.Screen + 40*1,x
sta c64.Screen + 40*2,x
lda c64.Screen + 40*0,x
sta c64.Screen + 40*1,x
.for row=11, row>=0, row-=1
lda c64.Screen + 40*row,x
sta c64.Screen + 40*(row+1),x
.next
dex
bpl -

View File

@ -95,89 +95,4 @@ jsr_indirect_XY
jmp (SCRATCH_ZP1)
}
asm {
; ---- copy a 5 byte MFLT floating point variable to another place
; input: X/Y = source address, SCRATCH_ZPWORD1 = destination address
copy_mflt stx SCRATCH_ZP1
sty SCRATCH_ZPWORD1+1
ldy #0
lda (SCRATCH_ZP1),y
sta (SCRATCH_ZPWORD1),y
iny
lda (SCRATCH_ZP1),y
sta (SCRATCH_ZPWORD1),y
iny
lda (SCRATCH_ZP1),y
sta (SCRATCH_ZPWORD1),y
iny
lda (SCRATCH_ZP1),y
sta (SCRATCH_ZPWORD1),y
iny
lda (SCRATCH_ZP1),y
sta (SCRATCH_ZPWORD1),y
ldy SCRATCH_ZPWORD1+1
rts
}
asm {
; ---- add 1 to the MFLT pointed to by X/Y. Clobbers A, X, Y
float_add_one
stx SCRATCH_ZP1
sty SCRATCH_ZP2
txa
jsr c64.MOVFM ; fac1 = float XY
lda #<c64.FL_FONE
ldy #>c64.FL_FONE
jsr c64.FADD ; fac1 += 1
ldx SCRATCH_ZP1
ldy SCRATCH_ZP2
jmp c64.FTOMEMXY ; float XY = fac1
; ---- subtract 1 from the MFLT pointed to by X/Y. Clobbers A, X, Y
float_sub_one
stx SCRATCH_ZP1
sty SCRATCH_ZP2
lda #<c64.FL_FONE
ldy #>c64.FL_FONE
jsr c64.MOVFM ; fac1 = 1
txa
ldy SCRATCH_ZP2
jsr c64.FSUB ; fac1 = float XY - 1
ldx SCRATCH_ZP1
ldy SCRATCH_ZP2
jmp c64.FTOMEMXY ; float XY = fac1
; ---- add MFLT pointed to by SCRATCH_ZPWORD1 to the MFLT pointed to by X/Y. Clobbers A, X, Y
float_add_SW1_to_XY
stx SCRATCH_ZP1
sty SCRATCH_ZP2
txa
jsr c64.MOVFM ; fac1 = float XY
lda SCRATCH_ZPWORD1
ldy SCRATCH_ZPWORD1+1
jsr c64.FADD ; fac1 += SCRATCH_ZPWORD1
ldx SCRATCH_ZP1
ldy SCRATCH_ZP2
jmp c64.FTOMEMXY ; float XY = fac1
; ---- subtract MFLT pointed to by SCRATCH_ZPWORD1 from the MFLT pointed to by X/Y. Clobbers A, X, Y
float_sub_SW1_from_XY
stx SCRATCH_ZP1
sty SCRATCH_ZP2
lda SCRATCH_ZPWORD1
ldy SCRATCH_ZPWORD1+1
jsr c64.MOVFM ; fac1 = SCRATCH_ZPWORD1
txa
ldy SCRATCH_ZP2
jsr c64.FSUB ; fac1 = float XY - SCRATCH_ZPWORD1
ldx SCRATCH_ZP1
ldy SCRATCH_ZP2
jmp c64.FTOMEMXY ; float XY = fac1
}
}

View File

@ -59,6 +59,15 @@ start
some_address = 4123.2342342222
[$c000.word] = # flt_pi
my_float ++
my_float += 1
my_float += 0.5
my_float += 999.222
my_float --
my_float -= 1
my_float -= 0.5
my_float -= 999.222
; print some floating points from source and compare them with ROM
printflt(#flt_pi)

View File

@ -15,8 +15,6 @@ import "c64lib"
start
c64.init_system()
c64.VMCSB += 2
c64.VMCSB *= 2
A = c64.VMCSB
A |= 2 ; @todo c64.VMCSB |= 2
c64.VMCSB = A
@ -37,7 +35,7 @@ start
c64.MUL10()
c64.FADDH()
c64.FADDH()
AY = c64.GETADRAY()
AY = c64flt.GETADRAY()
secretnumber = A
c64scr.print_string("I am thinking of a number from 1 to 100!You'll have to guess it!\n")
@ -58,7 +56,7 @@ ask_guess
c64.CHROUT('\n')
[$22.word] = guess
c64.FREADSTR(A)
AY = c64.GETADRAY()
AY = c64flt.GETADRAY()
A -= secretnumber ; @todo condition so we can do if guess > secretnumber....
if_zero goto correct_guess
if_gt goto too_high

View File

@ -5,7 +5,16 @@ output prg,basic
import "c64lib"
~ main {
const num = 44
var var1 =22
var .word wvar1 = 22
start
var1 ++
var1 += num
X++
X+=num
asm {
ldy #200
- lda #81
@ -42,7 +51,7 @@ start
loop
A=c64.GETIN()
if_not goto loop
c64scr.scroll_down_full(1)
c64scr.scroll_right_full(1)
goto loop
c64.CHROUT(A)
goto loop