DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦b535d68a1⟧ TextFile

    Length: 603 (0x25b)
    Types: TextFile
    Notes: UNIX file
    Names: »index.s«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »libc/gen/index.s« 

TextFile

/ Segmented Z8001 Coherent string library
/ Return addr of first occurence of char in string (or NULL if not found)
/ index(s1, c)
/ char *s1;
/ char c;

	.globl index_
	.globl SS

index_:
	ldl	rr2, SS|4(r15)		/ rr2 = s1
	ldl	rr4, rr2

	subl	rr0, rr0		/ r0 = count, r1 = NULL
	cpirb	rl1, (rr2), r0, eq	/ Scan string for '\0'
	neg	r0			/ r0 = string length (plus '\0')

	ldl	rr2, rr4		/ rr2 = s1
	ld	r1, SS|8(r15)		/ r1 = c
	cpirb	rl1, (rr2), r0, eq	/ Scan string for c

	jr	ne, 1f			/ Not found
	dec	r3, $1			/ Back to character
	ldl	rr0, rr2		/ Return pointer to c
	ret

1:
	subl	rr0, rr0		/ NULL
	ret