Code:
void lcd_printf_xy_p(uint8_t x, uint8_t y, const prog_char * fmt, ...) {
char temp[16];
va_list argp;
__builtin_va_start(argp,fmt);
vsprintf_P(temp, fmt, argp);
__builtin_va_end(argp);
lcd_gotoxy(x, y);
lcd_write(temp);
}
void foo(int val)
{
lcd_printf_xy_p(1, 2, ({static char __c[] __attribute__((__progmem__)) = ("Hallo %d"); __c;}), val);
}
*.s:
Code:
.global lcd_printf_xy_p
.type lcd_printf_xy_p, @function
lcd_printf_xy_p:
/* prologue: frame size=16 */
push r16
push r17
push r28
push r29
in r28,__SP_L__
in r29,__SP_H__
sbiw r28,16
in __tmp_reg__,__SREG__
cli
out __SP_H__,r29
out __SREG__,__tmp_reg__
out __SP_L__,r28
/* prologue end (size=12) */
ldd r16,Y+23 ; x, x ; 3 *movqi/4 [length = 1]
ldd r17,Y+24 ; y, y ; 4 *movqi/4 [length = 1]
ldd r24,Y+25 ; fmt, fmt ; 5 *movhi/2 [length = 2]
ldd r25,Y+26 ; fmt, fmt
movw r20,r28 ; argp, ; 37 *movhi/1 [length = 1]
subi r20,lo8(-(27)) ; argp, ; 16 *addhi3/4 [length = 2]
sbci r21,hi8(-(27)) ; argp,
movw r22,r24 ; fmt, fmt ; 17 *movhi/1 [length = 1]
movw r24,r28 ; , ; 38 *movhi/1 [length = 1]
adiw r24,1 ; , ; 18 *addhi3/2 [length = 1]
rcall vsprintf_P ; ; 19 call_value_insn/3 [length = 1]
mov r24,r17 ; y, y ; 22 zero_extendqihi2/2 [length = 2]
clr r25 ; y
movw r22,r24 ; y, y ; 24 *movhi/1 [length = 1]
mov r24,r16 ; x, x ; 25 zero_extendqihi2/2 [length = 2]
clr r25 ; x
rcall lcd_gotoxy ; ; 26 call_value_insn/3 [length = 1]
movw r24,r28 ; , ; 39 *movhi/1 [length = 1]
adiw r24,1 ; , ; 28 *addhi3/2 [length = 1]
rcall lcd_write ; ; 29 call_value_insn/3 [length = 1]
/* epilogue: frame size=16 */
adiw r28,16
in __tmp_reg__,__SREG__
cli
out __SP_H__,r29
out __SREG__,__tmp_reg__
out __SP_L__,r28
pop r29
pop r28
pop r17
pop r16
ret
/* epilogue end (size=11) */
/* function lcd_printf_xy_p size 43 (20) */
.size lcd_printf_xy_p, .-lcd_printf_xy_p
.section .progmem.data
.type __c.0, @object
.size __c.0, 9
__c.0:
.string "Hallo %d"
.text
.global foo
.type foo, @function
foo:
/* prologue: frame size=0 */
/* prologue end (size=0) */
push r25 ; val ; 12 *pushhi/1 [length = 2]
push r24 ; val
ldi r24,lo8(__c.0) ; tmp42, ; 13 *movhi/4 [length = 2]
ldi r25,hi8(__c.0) ; tmp42,
push r25 ; tmp42 ; 14 *pushhi/1 [length = 2]
push r24 ; tmp42
ldi r24,lo8(2) ; tmp43, ; 15 *movqi/2 [length = 1]
push r24 ; tmp43 ; 16 *pushqi/1 [length = 1]
ldi r24,lo8(1) ; tmp44, ; 17 *movqi/2 [length = 1]
push r24 ; tmp44 ; 18 *pushqi/1 [length = 1]
rcall lcd_printf_xy_p ; ; 19 call_insn/3 [length = 1]
in r24,__SP_L__ ; ; 28 *movhi/7 [length = 2]
in r25,__SP_H__ ;
adiw r24,6 ; , ; 21 *addhi3/2 [length = 1]
in __tmp_reg__,__SREG__ ; 29 *movhi/6 [length = 5]
cli
out __SP_H__,r25 ;
out __SREG__,__tmp_reg__
out __SP_L__,r24 ;
/* epilogue: frame size=0 */
ret
Lesezeichen