;
.export deceaxy
- .importzp ptr4, sreg
+ .importzp sreg, tmp1
deceaxy:
- sty ptr4
+ sty tmp1
sec
- sbc ptr4
- sta ptr4
+ sbc tmp1
+ sta tmp1
txa
sbc #0
tax
lda sreg+1
sbc #0
sta sreg+1
- lda ptr4
+ lda tmp1
rts
;
.export tossubeax
.import addysp1
- .importzp sp, sreg, tmp1, tmp2
+ .importzp sp, sreg
tossubeax:
ldy #0
sec
- sta tmp1
- lda (sp),y
- sbc tmp1 ; byte 0
- sta tmp2 ; use as temp storage
+ eor #$FF
+ adc (sp),y ; byte 0
+ pha ; Save low byte
iny
- stx tmp1
- lda (sp),y
- sbc tmp1 ; byte 1
+ txa
+ eor #$FF
+ adc (sp),y ; byte 1
tax
iny
lda (sp),y
lda (sp),y
sbc sreg+1 ; byte 3
sta sreg+1
- lda tmp2 ; load byte 0
- jmp addysp1 ; drop TOS
+ pla ; Restore byte 0
+ jmp addysp1 ; Drop TOS
-;
+;
; Ullrich von Bassewitz, 07.04.2000
;
; CC65 runtime: -= operator
;
.export lsubeq1, lsubeqa, lsubeq
- .importzp sreg, ptr1, tmp1
+ .importzp sreg, ptr1
lsubeq1:
ldy #$00 ; Address low byte
sec
- sta tmp1
- lda (ptr1),y ; Load byte 0
- sbc tmp1
+ eor #$FF
+ adc (ptr1),y ; Subtract byte 0
sta (ptr1),y
pha ; Save byte 0 of result for later
iny ; Address byte 1
- stx tmp1
- lda (ptr1),y ; Load byte 1
- sbc tmp1
+ txa
+ eor #$FF
+ adc (ptr1),y ; Subtract byte 1
sta (ptr1),y
tax
sta (ptr1),y
sta sreg+1
- pla ; Retrieve byte 0 of result
+ pla ; Retrieve byte 0 of result
- rts ; Done
+ rts ; Done
; Ullrich von Bassewitz, 08.10.1998
;
; CC65 runtime: -= operator for longs on the stack
-;
+;
.export lsubeq0sp, lsubeqysp
- .importzp sp, sreg, tmp1, tmp2
+ .importzp sp, sreg
lsubeq0sp:
ldy #0
lsubeqysp:
sec
- sta tmp1
- stx tmp2
- lda (sp),y
- sbc tmp1
+ eor #$FF
+ adc (sp),y
sta (sp),y
- pha
+ pha ; Save low byte
iny
- lda (sp),y
- sbc tmp2
+ txa
+ eor #$FF
+ adc (sp),y
sta (sp),y
tax
iny
.export tossuba0, tossubax
.import addysp1
- .importzp sp, ptr1
+ .importzp sp
;
; AX = TOS - AX
tossuba0:
ldx #0
tossubax:
- sta ptr1
- stx ptr1+1
+ sec
+ eor #$FF
.ifpc02
- lda (sp) ; Get lo byte
- ldy #1 ; Hi index
+ adc (sp)
+ ldy #1
.else
ldy #0
- lda (sp),y ; Lo byte
- iny ; Hi index
+ adc (sp),y ; Subtract low byte
+ iny
.endif
- sec
- sbc ptr1
- sta ptr1 ; save lo byte
- lda (sp),y
- sbc ptr1+1
- tax
- lda ptr1
- jmp addysp1 ; drop TOS, set condition codes
+ pha ; Save high byte
+ txa
+ eor #$FF
+ adc (sp),y ; Subtract high byte
+ tax ; High byte into X
+ pla ; Restore low byte
+ jmp addysp1 ; drop TOS
;
.export subeq0sp, subeqysp
- .importzp sp, tmp1, tmp2
+ .importzp sp
subeq0sp:
ldy #0
subeqysp:
sec
- sta tmp1
- stx tmp2
- lda (sp),y
- sbc tmp1
+ eor #$FF
+ adc (sp),y
sta (sp),y
- pha
+ pha ; Save low byte
iny
- lda (sp),y
- sbc tmp2
+ txa
+ eor #$FF
+ adc (sp),y
sta (sp),y
tax
- pla
+ pla ; Restore low byte
rts