PageRenderTime 70ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/cc65-2.13.2/libsrc/runtime/laddeq.s

http://github.com/gilligan/snesdev
Assembly | 53 lines | 31 code | 14 blank | 8 comment | 0 complexity | 1d7eeac66efde1968ad1ca5bc087b521 MD5 | raw file
  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 increment is
  7. ; in ptr1, the high byte is in Y, and the increment is in eax.
  8. ;
  9. .export laddeq1, laddeqa, laddeq
  10. .importzp sreg, ptr1, tmp1
  11. laddeq1:
  12. lda #$01
  13. laddeqa:
  14. ldx #$00
  15. stx sreg
  16. stx sreg+1
  17. laddeq: sty ptr1+1 ; Store high byte of address
  18. ldy #$00 ; Address low byte
  19. clc
  20. adc (ptr1),y
  21. sta (ptr1),y
  22. pha ; Save byte 0 of result for later
  23. iny ; Address byte 1
  24. txa
  25. adc (ptr1),y ; Load byte 1
  26. sta (ptr1),y
  27. tax
  28. iny ; Address byte 2
  29. lda sreg
  30. adc (ptr1),y
  31. sta (ptr1),y
  32. sta sreg
  33. iny ; Address byte 3
  34. lda sreg+1
  35. adc (ptr1),y
  36. sta (ptr1),y
  37. sta sreg+1
  38. pla ; Retrieve byte 0 of result
  39. rts ; Done