* Copyright (c) 1985 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)gets.s 5.4 (Berkeley) 6/27/88"
#endif /* LIBC_SCCS and not lint */
* argument: a target string
* side effects: reads bytes up to and including a newline from the
* standard input into the target string and replaces the newline
* with a null to null-terminate the string.
* result: the target string if successful, 0 otherwise.
* If no characters, call _filbuf() to get some.
tstl r0 /* What did _filbuf() return? */
movb r0,(S)+ /* Save the returned character */
tstl _BASE(IPTR) /* Is input buffered? */
* Look for a newline in the buffer.
locc $NL,_CNT(IPTR),*_PTR(IPTR)
* Success -- copy the data and return.
movc3 r2,*_PTR(IPTR),(S) /* Copy the data */
decl _CNT(IPTR) /* Skip the newline */
* If we run out of characters, copy the buffer and loop.
movc3 _CNT(IPTR),*_PTR(IPTR),(S) /* Copy the data */
movl _BASE(IPTR),_PTR(IPTR) /* Reset stdio */
* End of file? Check to see if we copied any data.
* Error/eof return -- null pointer.