From: IrgendwerA8 Date: Mon, 28 May 2018 23:47:04 +0000 (+0200) Subject: Free 2 bytes again. X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=refs%2Fpull%2F668%2Fhead;p=cc65 Free 2 bytes again. --- diff --git a/libsrc/runtime/mul.s b/libsrc/runtime/mul.s index 769cf9d8e..087e639fc 100644 --- a/libsrc/runtime/mul.s +++ b/libsrc/runtime/mul.s @@ -19,12 +19,12 @@ tosumulax: txa ; High byte zero beq @L3 ; Do 8x16 multiplication if high byte zero stx ptr4+1 ; Save right operand - jsr popptr1 ; Get left operand (Y=0 by popptr1) + jsr popptr1 ; Get left operand (Y=0, X untouched by popptr1) ; Do ptr4:ptr4+1 * ptr1:ptr1+1 --> AX - tya ; A = 0 - ldx ptr1+1 ; check if lhs is 8 bit only + tya ; A = 0 + ldy ptr1+1 ; check if lhs is 8 bit only beq @L4 ; -> we can do 8x16 after swap sta tmp1 ldy #16 ; Number of bits @@ -36,7 +36,7 @@ tosumulax: clc adc ptr1 tax - lda ptr1+1 ; hi byte of left op + lda ptr1+1 ; Hi byte of left op adc tmp1 sta tmp1 txa @@ -56,15 +56,15 @@ tosumulax: @L3: jmp mul8x16 -; If the high byte of rhs is zero, swap the operands and use the 8x16 -; routine. On entry, A and X are zero +; If the high byte of lhs is zero, swap the operands in ptr1/4 and +; use the 8x16 routine. On entry, A and Y are zero and X has the value +; of ptr4+1 -@L4: ldy ptr1 ; Save right operand (8 bit) +@L4: stx ptr1+1 ; Store hi-byte from ptr4 + ldy ptr1 ; Save right operand (8 bit) ldx ptr4 ; Copy left 16 bit operand to right stx ptr1 - ldx ptr4+1 ; swap high-byte too - stx ptr1+1 sty ptr4 ; Copy low 8 bit of right op to left ldy #8 - jmp mul8x16a + jmp mul8x16a ; There, ptr4+1 will be also cleared