summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/avremu/test-suite/printf.c
blob: e8d14fb07826fe482b439aefd865ce0091ddc7c9 (plain)
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
#include <avr/io.h>
#include <stdio.h>

char buffer[30];

volatile char buf[3];

static int uart_putchar(char c, FILE *stream);
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,
                                         _FDEV_SETUP_WRITE);
static int
uart_putchar(char c, FILE *stream)
{
    UDR = c;
    return 0;
}


int
main(void)
{
    stdout = &mystdout;

    buf[0] = 'x';
    buf[1] = 'y';
    buf[2] = '\0';

    puts(buf);


    asm volatile("break;");

    printf(":%c", buf[0]);

    asm volatile("break;");

    printf(":%d:", buf[1]);

    asm volatile("break;");

    volatile float x=0.23;
    printf(":%.2f:", x);

    asm volatile("break;");

    return 0;
}


/**
   check-name: Print to Stdout
   compiler-opts: -Wl,-u,vfprintf -lm -lprintf_flt
   check-start:

   \avr@instr@stepn{100000}
   \avr@test@UDR{xy^10} % ^10 == \n
   \def\avr@UDR{}

   \avr@instr@stepn{100000}
   \avr@test@UDR{:x}

   \avr@instr@stepn{100000}
   \avr@test@UDR{:121:}

   \avr@instr@stepn{100000}
   \avr@test@UDR{:0.23:}

   check-end:
**/