-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathputs.s
More file actions
139 lines (130 loc) · 2.23 KB
/
puts.s
File metadata and controls
139 lines (130 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
;
; File generated by cc65 v 2.13.9
;
.fopt compiler,"cc65 v 2.13.9"
.setcpu "6502"
.smart on
.autoimport on
.case on
.debuginfo on
.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
.macpack longbranch
.dbg file, "puts.c", 636, 1255247227
.dbg file, "../../include/stdio.h", 5964, 1255247211
.dbg file, "../../include/stddef.h", 2972, 1255247211
.dbg file, "../../include/stdarg.h", 2817, 1255247211
.dbg file, "../../include/string.h", 4883, 1255247211
.dbg file, "../../include/unistd.h", 3912, 1255247211
.dbg file, "./_file.h", 742, 1255247227
.import _stdout
.export _puts
.import _strlen
.import _write
; ---------------------------------------------------------------
; int __near__ __fastcall__ puts (__near__ const unsigned char*)
; ---------------------------------------------------------------
.segment "CODE"
.proc _puts: near
.segment "DATA"
L0004:
.byte $0D
.segment "CODE"
;
; {
;
.dbg line, "puts.c", 23
jsr pushax
;
; if (write (stdout->f_fd, s, strlen (s)) < 0 ||
;
.dbg line, "puts.c", 27
jsr decsp4
lda _stdout
sta ptr1
lda _stdout+1
sta ptr1+1
ldy #$00
lda (ptr1),y
ldy #$02
sta (sp),y
iny
lda #$00
sta (sp),y
ldy #$05
lda (sp),y
tax
dey
lda (sp),y
ldy #$00
sta (sp),y
iny
txa
sta (sp),y
ldy #$05
lda (sp),y
tax
dey
lda (sp),y
jsr _strlen
jsr _write
cpx #$80
bcs L0014
;
; write (stdout->f_fd, &nl, 1) < 0) {
;
.dbg line, "puts.c", 28
jsr decsp4
lda _stdout
sta ptr1
lda _stdout+1
sta ptr1+1
ldy #$00
lda (ptr1),y
ldy #$02
sta (sp),y
iny
lda #$00
sta (sp),y
lda #<(L0004)
ldy #$00
sta (sp),y
iny
lda #>(L0004)
sta (sp),y
ldx #$00
tya
jsr _write
cpx #$80
bcc L0006
;
; stdout->f_flags |= _FERROR;
;
.dbg line, "puts.c", 29
L0014: lda _stdout
sta ptr1
lda _stdout+1
sta ptr1+1
ldy #$01
lda (ptr1),y
ora #$04
sta (ptr1),y
;
; return -1;
;
.dbg line, "puts.c", 30
ldx #$FF
txa
jmp incsp2
;
; return 0;
;
.dbg line, "puts.c", 34
L0006: ldx #$00
txa
;
; }
;
.dbg line, "puts.c", 35
jmp incsp2
.dbg line
.endproc