]> git.sur5r.net Git - cc65/blob - libsrc/serial/ser_unload.s
Working on new serial API
[cc65] / libsrc / serial / ser_unload.s
1 ;
2 ; Ullrich von Bassewitz, 2003-04-15
3 ;
4 ; unsigned char __fastcall__ ser_unload (void);
5 ; /* Unload the currently loaded driver. */
6
7
8         .import         ser_clear_ptr
9
10         .include        "ser-kernel.inc"
11         .include        "ser-error.inc"
12         .include        "modload.inc"
13
14
15 _ser_unload:
16         lda     _ser_drv
17         ora     _ser_drv+1
18         beq     no_driver               ; No driver
19
20         jsr     ser_uninstall           ; Deinstall the driver
21
22         lda     _ser_drv
23         ldx     _ser_drv+1
24         jsr     _mod_free               ; Free the driver
25
26         jmp     ser_clear_ptr           ; Clear the driver pointer, return zero
27
28 no_driver:
29         tax                             ; X = 0
30         lda     #SER_ERR_NO_DRIVER
31         rts
32