mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
implemented last remaining codegen for word-byte division and remainders.
This commit is contained in:
parent
d840975054
commit
4cae2c56ec
@ -1 +1 @@
|
||||
6.4-SNAPSHOT
|
||||
6.4
|
||||
|
@ -1051,20 +1051,47 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
}
|
||||
"/" -> {
|
||||
if(dt==DataType.UWORD) {
|
||||
TODO("uwordvar / bytevar")
|
||||
asmgen.out("""
|
||||
lda $name
|
||||
ldy $name+1
|
||||
sta P8ZP_SCRATCH_W1
|
||||
sty P8ZP_SCRATCH_W1+1
|
||||
lda $otherName
|
||||
ldy #0
|
||||
jsr math.divmod_uw_asm
|
||||
sta $name
|
||||
sty $name+1
|
||||
""")
|
||||
} else {
|
||||
TODO("wordvar / bytevar")
|
||||
asmgen.out("""
|
||||
lda $name
|
||||
ldy $name+1
|
||||
sta P8ZP_SCRATCH_W1
|
||||
sty P8ZP_SCRATCH_W1+1
|
||||
lda $otherName
|
||||
ldy #0
|
||||
jsr math.divmod_w_asm
|
||||
sta $name
|
||||
sty $name+1
|
||||
""")
|
||||
}
|
||||
}
|
||||
"%" -> {
|
||||
if(valueDt!=DataType.UBYTE || dt!=DataType.UWORD)
|
||||
throw AssemblyError("% expects unsigned operands")
|
||||
if(dt==DataType.UWORD) {
|
||||
TODO("uwordvar % ubytevar")
|
||||
} else {
|
||||
TODO("wordvar % ubytevar")
|
||||
}
|
||||
}
|
||||
throw AssemblyError("remainder of signed integers is not properly defined/implemented, use unsigned instead")
|
||||
asmgen.out("""
|
||||
lda $name
|
||||
ldy $name+1
|
||||
sta P8ZP_SCRATCH_W1
|
||||
sty P8ZP_SCRATCH_W1+1
|
||||
lda $otherName
|
||||
ldy #0
|
||||
jsr math.divmod_uw_asm
|
||||
lda P8ZP_SCRATCH_W2
|
||||
sta $name
|
||||
lda P8ZP_SCRATCH_W2+1
|
||||
sta $name+1
|
||||
""") }
|
||||
"<<" -> {
|
||||
asmgen.out("""
|
||||
ldy $otherName
|
||||
|
@ -5,41 +5,7 @@ main {
|
||||
|
||||
sub start() {
|
||||
|
||||
word wvar
|
||||
word wvar2
|
||||
uword uwvar
|
||||
uword uwvar2
|
||||
byte bvar
|
||||
byte bvar2
|
||||
ubyte ubvar
|
||||
|
||||
uwvar result
|
||||
|
||||
uwvar = 49999
|
||||
uwvar2 = 1234
|
||||
result = uwvar / uwvar2
|
||||
txt.print_uw(result)
|
||||
result = uwvar % uwvar2
|
||||
txt.print_uw(result)
|
||||
|
||||
; uwvar %= uwvar2
|
||||
|
||||
|
||||
; wvar /= bvar
|
||||
; uwvar /= bvar
|
||||
; uwvar %= ubvar
|
||||
|
||||
|
||||
|
||||
; ubyte[] array = [1,2,3,4]
|
||||
; ubyte ix
|
||||
;
|
||||
; ubyte a = array[1] + array[ix]
|
||||
; a = array[ix] + array[ix]
|
||||
; a = array[ix+1] + array[ix]
|
||||
; uword multiple=0
|
||||
; a = array[lsb(multiple)] + array[ix]
|
||||
|
||||
txt.print("hello")
|
||||
|
||||
; str filename = "titlescreen.bin"
|
||||
; ubyte success = cx16.vload(filename, 8, 0, $0000)
|
||||
|
Loading…
Reference in New Issue
Block a user