]> git.sur5r.net Git - cc65/blob - libsrc/atmos/write.s
Remove trailings spaces from CBM-related asm files
[cc65] / libsrc / atmos / write.s
1 ;
2 ; Ullrich von Bassewitz, 2003-04-13
3 ;
4 ; int write (int fd, const void* buf, int count);
5 ;
6 ; This function is a hack!
7 ;
8
9         .export         _write
10         .import         popax, popptr1
11         .importzp       ptr1, ptr2, ptr3, tmp1
12
13         .include        "atmos.inc"
14
15 .proc   _write
16
17         sta     ptr3
18         stx     ptr3+1          ; save count as result
19
20         eor     #$FF
21         sta     ptr2
22         txa
23         eor     #$FF
24         sta     ptr2+1          ; Remember -count-1
25
26         jsr     popptr1         ; get buf
27         jsr     popax           ; get fd and discard
28 L1:     inc     ptr2
29         bne     L2
30         inc     ptr2+1
31         beq     L9
32 L2:     ldy     #0
33         lda     (ptr1),y
34         tax
35         cpx     #$0A            ; Check for \n
36         bne     L3
37         jsr     PRINT
38         ldx     #$0D
39 L3:     jsr     PRINT
40         inc     ptr1
41         bne     L1
42         inc     ptr1+1
43         jmp     L1
44
45 ; No error, return count
46
47 L9:     lda     ptr3
48         ldx     ptr3+1
49         rts
50
51 .endproc
52
53