File: cbm_filetype.s

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (71 lines) | stat: -rw-r--r-- 1,655 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
;
; Determine the CBM file type. From cbm_dir.c by Josef Soucek. Moved into an
; assembler function by Ullrich von Bassewitz 2012-06-03
;
; unsigned char __fastcall__ _cbm_filetype (unsigned char c);
;

        .include "cbm_filetype.inc"

        .macpack generic


; --------------------------------------------------------------------------
; Table with types for a list of start characters

.rodata
.proc   TypeTable
        .byte   CBM_T_CBM       ; c
        .byte   CBM_T_DEL       ; d
        .byte   CBM_T_OTHER     ; e
        .byte   CBM_T_OTHER     ; f
        .byte   CBM_T_OTHER     ; g
        .byte   CBM_T_OTHER     ; h
        .byte   CBM_T_OTHER     ; i
        .byte   CBM_T_OTHER     ; j
        .byte   CBM_T_OTHER     ; k
        .byte   CBM_T_LNK       ; l
        .byte   CBM_T_OTHER     ; m
        .byte   CBM_T_OTHER     ; n
        .byte   CBM_T_OTHER     ; o
        .byte   CBM_T_PRG       ; p
        .byte   CBM_T_OTHER     ; q
        .byte   CBM_T_REL       ; r
        .byte   CBM_T_SEQ       ; s
        .byte   CBM_T_OTHER     ; t
        .byte   CBM_T_USR       ; u
        .byte   CBM_T_VRP       ; v
.endproc


; --------------------------------------------------------------------------
; Mapper function

.code
.proc   __cbm_filetype

        ldx     #0              ; Clear high byte

; Check that the given char is in table range

        sec
        sbc     #'c'
        bcc     L1
        cmp     #.sizeof (TypeTable)
        bge     L1

; Ok, load the type

        tay
        lda     TypeTable,y
        rts

; Out of table range, return CBM_T_OTHER

L1:     lda     #CBM_T_OTHER
        rts

.endproc