2 ; Ullrich von Bassewitz, 13.08.1998
4 ; CC65 runtime: helper stuff for mod/div/mul with long signed ints
7 ; When negating values, we will ignore the possibility here, that one of the
8 ; values if $80000000, in which case the negate will fail.
10 .export poplsargs, adjlsres
11 .import getlop, negeax
12 .importzp sreg, tmp1, ptr1, ptr3, ptr4
15 jsr getlop ; Get the operands
17 ; Calculate the sign of the result, that is sign(op1) * sign(op2) and
22 sta tmp1 ; Save it across call
24 ; Make both operands positive
26 lda sreg+1 ; Is the operand negative?
29 clc ; Make it positive
47 L1: lda ptr4+1 ; Is the operand nagative?
50 clc ; Make it positive
70 ; Adjust the result of a mod/div/mul operation
73 ldy tmp1 ; Check if we must adjust the sign
75 jmp negeax ; Netage value