/[projet1]/public/pc/tools/osdk/main/Osdk/_final_/lib2/printf.s
Defence Force logotype

Contents of /public/pc/tools/osdk/main/Osdk/_final_/lib2/printf.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1154 - (show annotations)
Sun Aug 10 18:19:54 2014 UTC (5 years, 6 months ago) by dbug
File size: 2356 byte(s)


1 ;
2 ; printf(char *format,...)
3 ;
4 _printf
5 lda #<putchar
6 sta printvect+1
7 lda #>putchar
8 sta printvect+2
9 ldy #0
10 jmp printf
11
12 printvect jmp $0238
13
14 storechar
15 sta $1234
16 inc storechar+1
17 bne *+5
18 inc storechar+2
19 rts
20
21 ;
22 ; sprintf(char *format,...)
23 ;
24 _sprintf
25 lda #<storechar
26 sta printvect+1
27 lda #>storechar
28 sta printvect+2
29
30 ldy #0
31 lda (sp),y
32 sta storechar+1
33 iny
34 lda (sp),y
35 sta storechar+2
36 iny
37
38 printf
39 lda (sp),y
40 sta tmp
41 iny
42 lda (sp),y
43 sta tmp+1
44 iny
45 sty saveptrarg
46
47 ldy #0
48 formloop
49 lda (tmp),y
50 tax
51 beq endform
52 cmp #$25 ; '%'
53 beq formfield
54 charput
55 jsr printvect
56 iny
57 bne formloop ; size format string < 256
58 endform
59 rts
60 printfloat
61 iny
62 sty saveptrform
63 clc
64 lda sp
65 adc saveptrarg
66 tax
67 lda sp+1
68 adc #0
69 tay
70 txa
71 jsr load_acc1
72 jsr $E0D5
73 sta op2
74 sty op2+1
75 clc
76 lda saveptrarg
77 adc #5
78 sta saveptrarg
79 ldy #0
80 jmp prtsloop
81
82 formfield
83 iny
84 lda (tmp),y
85 cmp #$64 ; 'd'
86 beq printint
87 cmp #$66 ; 'f'
88 beq printfloat
89 cmp #$73 ; 's'
90 beq printstr
91 cmp #$63 ; 'c'
92 beq printchar
93 cmp #$78 ; 'x'
94 beq printhex
95 jmp charput
96 printchar
97 sty saveptrform
98 ldy saveptrarg
99 lda (sp),y
100 tax
101 iny
102 iny
103 sty saveptrarg
104 ldy saveptrform
105 jmp charput
106 printstr
107 iny
108 sty saveptrform
109 ldy saveptrarg
110 lda (sp),y
111 sta op2
112 iny
113 lda (sp),y
114 sta op2+1
115 iny
116 sty saveptrarg
117 ldy #0
118 prtsloop
119 lda (op2),y
120 tax
121 beq endprts
122 jsr printvect
123 iny
124 bne prtsloop
125 inc op2+1
126 jmp prtsloop
127 endprts
128 ldy saveptrform
129 jmp formloop
130 printint
131 iny
132 sty saveptrform
133 jsr nextarg
134 jsr itoa
135 stx op2
136 sta op2+1
137 ldy #0
138 jmp prtsloop
139
140 printhex
141 iny
142 sty saveptrform
143 jsr nextarg
144 lda op2+1
145 jsr hexbyte
146 lda op2
147 jsr hexbyte
148 ldy saveptrform
149 jmp formloop
150
151 saveptrform
152 .byt 0
153 saveform
154 .byt 0,0
155 saveptrarg
156 .byt 0
157
158 hexbyte
159 tay
160 lsr
161 lsr
162 lsr
163 lsr
164 jsr nibble
165 tya
166 and #$0F
167 nibble
168 cmp #10
169 bcc chiffre
170 adc #6
171 chiffre
172 adc #$30
173 tax
174 jmp printvect
175
176 nextarg
177 ldy saveptrarg
178 lda (sp),y
179 sta op2
180 iny
181 lda (sp),y
182 sta op2+1
183 iny
184 sty saveptrarg
185 rts

  ViewVC Help
Powered by ViewVC 1.1.26