mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 01:29:28 +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:
|
||||
|
||||
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
|
||||
bpl lsr_ubyte_A
|
||||
- sec
|
||||
ror a
|
||||
dey
|
||||
bne -
|
||||
rts
|
||||
+ rts
|
||||
.pend
|
||||
|
||||
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
|
||||
dey
|
||||
bne -
|
||||
rts
|
||||
+ rts
|
||||
.pend
|
||||
|
||||
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
|
||||
dey
|
||||
bne -
|
||||
rts
|
||||
+ rts
|
||||
.pend
|
||||
|
||||
|
||||
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
|
||||
bpl lsr_uword_AY
|
||||
sty P8ZP_SCRATCH_B1
|
||||
_negative sec
|
||||
- sec
|
||||
ror P8ZP_SCRATCH_B1
|
||||
ror a
|
||||
dex
|
||||
bne _negative
|
||||
bne -
|
||||
ldy P8ZP_SCRATCH_B1
|
||||
rts
|
||||
+ rts
|
||||
.pend
|
||||
|
||||
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
|
||||
- lsr P8ZP_SCRATCH_B1
|
||||
ror a
|
||||
dex
|
||||
bne -
|
||||
ldy P8ZP_SCRATCH_B1
|
||||
rts
|
||||
+ rts
|
||||
.pend
|
||||
|
||||
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
|
||||
- asl a
|
||||
rol P8ZP_SCRATCH_B1
|
||||
dex
|
||||
bne -
|
||||
ldy P8ZP_SCRATCH_B1
|
||||
rts
|
||||
+ rts
|
||||
.pend
|
||||
|
||||
|
||||
|
@ -1,8 +1,16 @@
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
print('@')
|
||||
}
|
||||
|
||||
sub print(str message) {
|
||||
ubyte value = 1
|
||||
uword wvalue = 1
|
||||
ubyte zero = 0
|
||||
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