mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
fix code for bitwise shifts by zero
This commit is contained in:
parent
f98ee326b4
commit
be06d871b6
@ -847,67 +847,79 @@ mul_word_640 .proc
|
|||||||
; support for bit shifting that is too large to be unrolled:
|
; support for bit shifting that is too large to be unrolled:
|
||||||
|
|
||||||
lsr_byte_A .proc
|
lsr_byte_A .proc
|
||||||
; -- lsr signed byte in A times the value in Y (>1)
|
; -- lsr signed byte in A times the value in Y
|
||||||
|
cpy #0
|
||||||
|
beq +
|
||||||
cmp #0
|
cmp #0
|
||||||
bpl lsr_ubyte_A
|
bpl lsr_ubyte_A
|
||||||
- sec
|
- sec
|
||||||
ror a
|
ror a
|
||||||
dey
|
dey
|
||||||
bne -
|
bne -
|
||||||
rts
|
+ rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
lsr_ubyte_A .proc
|
lsr_ubyte_A .proc
|
||||||
; -- lsr unsigned byte in A times the value in Y (>1)
|
; -- lsr unsigned byte in A times the value in Y
|
||||||
|
cpy #0
|
||||||
|
beq +
|
||||||
- lsr a
|
- lsr a
|
||||||
dey
|
dey
|
||||||
bne -
|
bne -
|
||||||
rts
|
+ rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
asl_byte_A .proc
|
asl_byte_A .proc
|
||||||
; -- asl any byte in A times the value in Y (>1)
|
; -- asl any byte in A times the value in Y
|
||||||
|
cpy #0
|
||||||
|
beq +
|
||||||
- asl a
|
- asl a
|
||||||
dey
|
dey
|
||||||
bne -
|
bne -
|
||||||
rts
|
+ rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
|
|
||||||
lsr_word_AY .proc
|
lsr_word_AY .proc
|
||||||
; -- lsr signed word in AY times the value in X (>1)
|
; -- lsr signed word in AY times the value in X
|
||||||
|
cpx #0
|
||||||
|
beq +
|
||||||
cpy #0
|
cpy #0
|
||||||
bpl lsr_uword_AY
|
bpl lsr_uword_AY
|
||||||
sty P8ZP_SCRATCH_B1
|
sty P8ZP_SCRATCH_B1
|
||||||
_negative sec
|
- sec
|
||||||
ror P8ZP_SCRATCH_B1
|
ror P8ZP_SCRATCH_B1
|
||||||
ror a
|
ror a
|
||||||
dex
|
dex
|
||||||
bne _negative
|
bne -
|
||||||
ldy P8ZP_SCRATCH_B1
|
ldy P8ZP_SCRATCH_B1
|
||||||
rts
|
+ rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
lsr_uword_AY .proc
|
lsr_uword_AY .proc
|
||||||
; -- lsr unsigned word in AY times the value in X (>1)
|
; -- lsr unsigned word in AY times the value in X
|
||||||
|
cpx #0
|
||||||
|
beq +
|
||||||
sty P8ZP_SCRATCH_B1
|
sty P8ZP_SCRATCH_B1
|
||||||
- lsr P8ZP_SCRATCH_B1
|
- lsr P8ZP_SCRATCH_B1
|
||||||
ror a
|
ror a
|
||||||
dex
|
dex
|
||||||
bne -
|
bne -
|
||||||
ldy P8ZP_SCRATCH_B1
|
ldy P8ZP_SCRATCH_B1
|
||||||
rts
|
+ rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
asl_word_AY .proc
|
asl_word_AY .proc
|
||||||
; -- asl any word in AY times the value in X (>1)
|
; -- asl any word in AY times the value in X
|
||||||
|
cpx #0
|
||||||
|
beq +
|
||||||
sty P8ZP_SCRATCH_B1
|
sty P8ZP_SCRATCH_B1
|
||||||
- asl a
|
- asl a
|
||||||
rol P8ZP_SCRATCH_B1
|
rol P8ZP_SCRATCH_B1
|
||||||
dex
|
dex
|
||||||
bne -
|
bne -
|
||||||
ldy P8ZP_SCRATCH_B1
|
ldy P8ZP_SCRATCH_B1
|
||||||
rts
|
+ rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
|
%import textio
|
||||||
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
print('@')
|
ubyte value = 1
|
||||||
}
|
uword wvalue = 1
|
||||||
|
ubyte zero = 0
|
||||||
sub print(str message) {
|
txt.print_ub(value<<zero) ; TODO fix result 6502 codegen! should be 1.
|
||||||
|
txt.print_uw(wvalue<<zero) ; TODO fix result 6502 codegen! should be 1.
|
||||||
|
ubyte value2 = value<<zero ; result is ok, 1
|
||||||
|
uword wvalue2 = wvalue<<zero ; result is ok, 1
|
||||||
|
txt.print_ub(value2)
|
||||||
|
txt.print_uw(wvalue2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user