2 ; Christian Krueger, 24-May-2018
4 ; CC65 runtime: division for signed ints
7 ; When negating values, we will ignore the possibility here, that one of the
8 ; values is $8000, in which case the negate will fail.
10 .export tosdiva0, tosdivax
11 .import absvaludiv, negax
12 .importzp sp, ptr1, tmp1
17 pha ; check if high-bytes indicate
18 txa ; different sign, so that we
19 ldy #1 ; negate the result after the operation
20 eor (sp),y ; eor with lhs high byte
21 sta tmp1 ; save post negation indicator to tmp1
22 pla ; back to entry accu
26 ldy tmp1 ; fetch idicator