]> git.sur5r.net Git - cc65/blob - libsrc/common/utscopy.s
add support for detecting 45GS02
[cc65] / libsrc / common / utscopy.s
1 ;
2 ; Ullrich von Bassewitz, 2003-08-12
3 ;
4 ; This module contains a utility function for the machine dependent parts
5 ; of uname (__sysuname): It copies a packed struct utsname (just the strings
6 ; without padding) into a struct utsname. The source of the data is an
7 ; external symbol named "utsdata", the target is passed in a/x.
8 ; The function is written so that it is a direct replacement for __sysuname
9 ; for systems where utsdata is fixed. It may also be called via jump or
10 ; subroutine on systems where utsdata must be changed at runtime.
11 ;
12
13         .export         utscopy
14
15         .import         utsdata
16         .importzp       ptr1, tmp1
17
18         .include        "utsname.inc"
19
20
21
22 ;--------------------------------------------------------------------------
23 ; Data.
24
25 .rodata
26
27 ; Table with offsets into struct utsname
28 fieldoffs:
29         .byte   utsname::sysname
30         .byte   utsname::nodename
31         .byte   utsname::release
32         .byte   utsname::version
33         .byte   utsname::machine
34
35 fieldcount = * - fieldoffs
36
37 ;--------------------------------------------------------------------------
38
39 .code
40
41 .proc   utscopy
42
43         sta     ptr1
44         stx     ptr1+1          ; Save buf
45
46         ldx     #0
47         stx     tmp1            ; Field number
48
49 next:   ldy     tmp1
50         cpy     #fieldcount
51         beq     done
52         inc     tmp1            ; Bump field counter
53         lda     fieldoffs,y     ; Get next field offset
54         tay                     ; Field offset -> y
55
56 loop:   lda     utsdata,x
57         sta     (ptr1),y
58         inx                     ; Next char in utsdata
59         cmp     #$00            ; Check for end of string
60         beq     next            ; Jump for next field
61         iny                     ; Next char in utsname struct
62         bne     loop            ; Copy string
63
64 done:   lda     #$00            ; Always successful
65         rts
66
67 .endproc
68
69