]> git.sur5r.net Git - cc65/blob - libsrc/runtime/lsubeq.s
The upper 16 bit differ between signed and unsigned multiplication, so while
[cc65] / libsrc / runtime / lsubeq.s
1 ;                                 
2 ; Ullrich von Bassewitz, 07.04.2000
3 ;
4 ; CC65 runtime: -= operator
5 ;
6 ; On entry, the low byte of the address of the variable to decrement is
7 ; in ptr1, the high byte is in Y, and the decrement is in eax.
8 ;
9
10         .export         lsubeq1, lsubeqa, lsubeq
11         .importzp       sreg, ptr1
12
13
14 lsubeq1:
15         lda     #$01
16
17 lsubeqa:
18         ldx     #$00
19         stx     sreg
20         stx     sreg+1
21
22 lsubeq: sty     ptr1+1                  ; Store high byte of address
23         ldy     #$00                    ; Address low byte
24         sec
25
26         eor     #$FF
27         adc     (ptr1),y                ; Subtract byte 0
28         sta     (ptr1),y
29         pha                             ; Save byte 0 of result for later
30
31         iny                             ; Address byte 1
32         txa
33         eor     #$FF
34         adc     (ptr1),y                ; Subtract byte 1
35         sta     (ptr1),y
36         tax
37
38         iny                             ; Address byte 2
39         lda     (ptr1),y
40         sbc     sreg
41         sta     (ptr1),y
42         sta     sreg
43
44         iny                             ; Address byte 3
45         lda     (ptr1),y
46         sbc     sreg+1
47         sta     (ptr1),y
48         sta     sreg+1
49
50         pla                             ; Retrieve byte 0 of result
51
52         rts                             ; Done
53
54
55
56