File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ .assume adl=1
2+
3+ ;-------------------------------------------------------------------------------
4+
5+ .section .text
6+ .global _perror
7+ .type _perror, @function
8+
9+ ; void perror(const char*)
10+ _perror:
11+ pop de
12+ ex (sp), hl
13+ push de
14+ add hl, bc
15+ xor a, a
16+ sbc hl, bc
17+ jr z, .L.null_string
18+ cp a, (hl)
19+ jr z, .L.empty_string
20+ ; fprintf(stderr, "%s: ", str)
21+ call .L.errchar_puts
22+ ld hl, _perror_colon_space_str
23+ call .L.errchar_puts
24+
25+ .L.null_string:
26+ .L.empty_string:
27+ ld hl, (_errno)
28+ call _strerror.hijack_hl
29+ call .L.errchar_puts
30+ ld a, $0A ; '\n'
31+ .L.errchar_putchar:
32+ ; input:
33+ ; - A = character to display
34+ ; - HL = nul terminated string to display afterward
35+ ; output:
36+ ; - HL points to nul terminator
37+ push hl
38+ ld l, a
39+ push hl
40+ call _errchar
41+ pop hl
42+ pop hl
43+ .L.errchar_puts:
44+ ld a, (hl)
45+ or a, a
46+ ret z
47+ inc hl
48+ jr .L.errchar_putchar
49+
50+ .extern _errno
51+ .extern _errchar
52+
53+ ;-------------------------------------------------------------------------------
54+
55+ .section .rodata._perror_colon_space_str
56+ .local _perror_colon_space_str
57+ _perror_colon_space_str:
58+ .asciz ": "
You can’t perform that action at this time.
0 commit comments