mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 19:29:37 +00:00
a1092ca7da
git-svn-id: svn://svn.cc65.org/cc65/trunk@2710 b7a2c559-68d2-44c3-8de9-860c34a00d81
70 lines
1.8 KiB
ArmAsm
70 lines
1.8 KiB
ArmAsm
;
|
|
; Ullrich von Bassewitz, 2003-08-12
|
|
;
|
|
; This module contains a utility function for the machine dependent parts
|
|
; of uname (__sysuname): It copies a packed struct utsname (just the strings
|
|
; without padding) into a struct utsname. The source of the data is an
|
|
; external symbol named "utsdata", the target is passed in a/x.
|
|
; The function is written so that it is a direct replacement for __sysuname
|
|
; for systems where utsdata is fixed. It may also be called via jump or
|
|
; subroutine on systems where utsdata must be changed at runtime.
|
|
;
|
|
|
|
.export utscopy
|
|
|
|
.import utsdata
|
|
.importzp ptr1, tmp1
|
|
|
|
.include "utsname.inc"
|
|
|
|
|
|
|
|
;--------------------------------------------------------------------------
|
|
; Data.
|
|
|
|
.rodata
|
|
|
|
; Table with offsets into struct utsname
|
|
fieldoffs:
|
|
.byte utsname::sysname
|
|
.byte utsname::nodename
|
|
.byte utsname::release
|
|
.byte utsname::version
|
|
.byte utsname::machine
|
|
|
|
fieldcount = * - fieldoffs
|
|
|
|
;--------------------------------------------------------------------------
|
|
|
|
.code
|
|
|
|
.proc utscopy
|
|
|
|
sta ptr1
|
|
stx ptr1+1 ; Save buf
|
|
|
|
ldx #0
|
|
stx tmp1 ; Field number
|
|
|
|
next: ldy tmp1
|
|
cpy #fieldcount
|
|
beq done
|
|
inc tmp1 ; Bump field counter
|
|
lda fieldoffs,y ; Get next field offset
|
|
tay ; Field offset -> y
|
|
|
|
loop: lda utsdata,x
|
|
sta (ptr1),y
|
|
inx ; Next char in utsdata
|
|
cmp #$00 ; Check for end of string
|
|
beq next ; Jump for next field
|
|
iny ; Next char in utsname struct
|
|
bne loop ; Copy string
|
|
|
|
done: lda #$00 ; Always successful
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|