]> git.sur5r.net Git - cc65/blob - libsrc/serial/ser_unload.s
Issue 814
[cc65] / libsrc / serial / ser_unload.s
1 ;
2 ; Ullrich von Bassewitz, 2003-04-15
3 ;
4 ; unsigned char ser_unload (void);
5 ; /* Unload the currently loaded driver. */
6
7
8         .include        "ser-kernel.inc"
9         .include        "ser-error.inc"
10         .include        "modload.inc"
11
12         .import         ser_clear_ptr
13         .import         return0
14
15
16
17 _ser_unload:
18         lda     _ser_drv
19         pha                             ; Save pointer to driver
20         ora     _ser_drv+1
21         beq     no_driver               ; No driver
22         lda     _ser_drv+1
23         pha
24
25         jsr     _ser_uninstall          ; Uninstall the driver
26
27         pla
28         tax
29         pla                             ; Get pointer to driver
30         jsr     _mod_free               ; Free the driver
31         jmp     return0                 ; Return SER_ERR_OK
32
33 no_driver:
34         tax                             ; X = 0
35         pla                             ; Remove pushed junk
36         lda     #<SER_ERR_NO_DRIVER
37         rts