Files
Sprinter-SDCC/libc/stdio/puts.c
T
snark13 737c974400 Add mdview markdown viewer, reorganize tests/examples and libc layout
- Split tests/ (libc feature tests) and examples/ (real apps); shared
  app.mk in repo root, was examples/example.mk
- libc/io/* split into libc/{conio,env,errno,file,mouse,string,sys,
  time,video}/ — clearer module boundaries
- New examples/mdview/: markdown viewer (Phases 1-5 + light nested
  lists). Headers (H1-H4), HR, ulist/olist/quote with nesting via
  leading spaces, fenced code blocks, inline emphasis (bold/italic/
  underscore/code), wrap/unwrap mode with soft wrap (F2), horizontal
  pan (← →) with '>' truncation indicator
- libc additions: scroll() in conio (ESTEX SCROLL), strlwr/strupr,
  gets() test
- Makefile updates across tests/ for the new shared app.mk path

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-04 22:23:36 +03:00

57 lines
1.3 KiB
C

/*
* puts — C99 fputs(s, stdout) + '\n'.
*
* Turbo-C convention: stdio's `puts` is the FAST path with NO attribute
* control — backed by ESTEX PCHARS ($5C). Cursor cell attributes are
* whatever ESTEX has cached (usually the shell's default).
*
* For coloured output use cputs() / cprintf() from <conio.h>.
*
* Implementation notes:
* - PCHARS does NOT translate '\n' to CR LF, so we copy the string
* into a static buffer expanding each '\n' to CR LF, then append
* the trailing CR LF before the NUL.
* - Avoid trailing PUTCHAR after PCHARS — empirically that sometimes
* drops the next char. Embed the line ending inside the PCHARS
* buffer instead.
*/
#include <stdio.h>
#include <stdint.h>
static void pchars(const char *s) __naked
{
(void)s;
__asm
push ix
ld c, #0x5C
rst #0x10
pop ix
ret
__endasm;
}
char puts(const char *s) __naked
{
(void)s;
__asm
puts_:
ld a, (hl)
or a
jr z, fin_
push hl
ld l, a
ld h, #0
call _putchar
pop hl
inc hl
jp puts_
;
fin_:
ld l, #0x0A
ld h, #0
call _putchar
ret
__endasm;
}