mais si ça tombe ça ne fait qu'afficher le résultat de sprintf(mêmes arguments)
Non, mais printf utilise sprintf pour trouver l'adresse de vcbprintf:
[code].xdef printf
.text
printf:
movea.l 0xC8,a0
movea.l (a0,0x14C),a0 /* vcbprintf */
lea (a0,32),a0
movea.w (a0),a1
pea (sp,8)
move.l (sp,8),-(sp)
clr.l -(sp)
pea fputchar
jsr (a0.l,a1)
lea (sp,16),sp
rts[/code]
fputchar est une fonction plus grosse:
[code].xdef fputchar
.text
fputchar:
link.w a6,#-20
movem.l d3-d7/a2-a5,-(sp)
clr.w d6
move.b (a6,9),d6
move.l 0xC8,a5
move.l (a5,1592),a0 /* FontGetSys */
jsr (a0)
ext.w d0 /* Yes, I know we technically shouldn't sign-extend an
unsigned char, but it is always positive anyway. */
move.w d0,d4
lsl.w #1,d4
addq.w #6,d4
move.l (a5,188),a3 /* ScrRect */
pea (a6,-18)
move.l (a5,1664),a0 /* SaveScrState */
jsr (a0)
move.w (a6,-8),d5
move.w (a6,-6),d3
move.w d6,-(sp)
move.l (a5,1600),a0 /* FontCharWidth */
jsr (a0)
move.w d0,d7
cmp.b #10,d6
jbeq .L__fputchar_1
move.w d5,d0
add.w d7,d0
clr.w d1
move.b (a3,2),d1
cmp.w d0,d1
jbge .L__fputchar_2
.L__fputchar_1:
clr.w d5
add.w d4,d3
.L__fputchar_2:
move.w d3,d0
add.w d4,d0
clr.w d1
move.b (a3,3),d1
cmp.w d0,d1
jbge .L__fputchar_3
clr.w (sp)
move.w d4,-(sp)
move.l a3,-(sp)
move.l a3,-(sp)
move.l (a5,1580),a0 /* ScrRectScroll */
jsr (a0)
sub.w d4,d3
.L__fputchar_3:
move.w #4,(sp)
move.w d6,-(sp)
move.w d3,-(sp)
move.w d5,-(sp)
cmp.b #10,d6
jbeq .L__fputchar_4
move.l (a5,1680),a0 /* DrawChar */
jsr (a0)
add.w d7,(sp)
.L__fputchar_4:
move.l (a5,1652),a0 /* MoveTo */
jsr (a0)
move.w d6,d0
movm.l -56(a6),d3-d7/a2-a5
unlk a6
rts[/code]
(d'ailleurs, c'est un peu dommage que vcbprintf fonctionne comme ça: à chaque caractère, fputchar entier est appelé, ce qui fait que plusieurs ROM_CALLs qui gardent le même effet et la même valeur pendant toutes les exécutions consécutives du callback - tant qu'on fait, sur cette plate-forme, de la programmation single-thread sans exécutions bizarres dans les handlers d'interruption - sont appelés plusieurs fois, alors qu'ils pourraient ne l'être qu'une seule fois

)