[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] float sizes
From: |
Theodore A. Roth |
Subject: |
[avr-gcc-list] float sizes |
Date: |
Sat, 9 Feb 2002 13:56:33 -0700 (MST) |
Hi,
I'm doing some more fix-ups on my avr-gdb patch and need to know sizes for
floats. Unless I hear otherwise, I'll use these assuptions:
sizeof(float) == 4 * sizeof(char)
sizeof(double) == 4 * sizeof(char)
sizeof(long double) == 4 * sizeof(char)
Also, I'm assuming litle endian IEEE format for float.
As a test, I wrote this program and compiled for 8515:
1 #include <stdlib.h>
2
3 int main( void )
4 {
5 float ff = 1.2;
6 double dd = 2.3;
7 long double ld = 3.4;
8
9 ff += 1.0;
10 dd += 1.0;
11 ld += 1.0;
12
13 return(0);
14 }
avr-gcc -g -Wall -mmcu=at90s8515 -c -o bug.o bug.c
avr-gcc -g -Wall -mmcu=at90s8515 -o bug bug.o
cp bug bug.elf
avr-objdump -h -S -D --disassemble-zeroes bug.elf > bug.lst
which generates this code (part of bug.lst):
82 int main( void )
83 {
84 56: c3 e5 ldi r28, 0x53 ; 83
85 58: d2 e0 ldi r29, 0x02 ; 2
86 5a: de bf out 0x3e, r29 ; 62
87 5c: cd bf out 0x3d, r28 ; 61
88 float ff = 1.2;
89 5e: 8a e9 ldi r24, 0x9A ; 154
90 60: 99 e9 ldi r25, 0x99 ; 153
91 62: a9 e9 ldi r26, 0x99 ; 153
92 64: bf e3 ldi r27, 0x3F ; 63
93 66: 89 83 std Y+1, r24 ; 0x01
94 68: 9a 83 std Y+2, r25 ; 0x02
95 6a: ab 83 std Y+3, r26 ; 0x03
96 6c: bc 83 std Y+4, r27 ; 0x04
97 double dd = 2.3;
98 6e: 83 e3 ldi r24, 0x33 ; 51
99 70: 93 e3 ldi r25, 0x33 ; 51
100 72: a3 e1 ldi r26, 0x13 ; 19
101 74: b0 e4 ldi r27, 0x40 ; 64
102 76: 8d 83 std Y+5, r24 ; 0x05
103 78: 9e 83 std Y+6, r25 ; 0x06
104 7a: af 83 std Y+7, r26 ; 0x07
105 7c: b8 87 std Y+8, r27 ; 0x08
106 long double ld = 3.4;
107 7e: 8a e9 ldi r24, 0x9A ; 154
108 80: 99 e9 ldi r25, 0x99 ; 153
109 82: a9 e5 ldi r26, 0x59 ; 89
110 84: b0 e4 ldi r27, 0x40 ; 64
111 86: 89 87 std Y+9, r24 ; 0x09
112 88: 9a 87 std Y+10, r25 ; 0x0a
113 8a: ab 87 std Y+11, r26 ; 0x0b
114 8c: bc 87 std Y+12, r27 ; 0x0c
115
116 ff += 1.0;
117 8e: 20 e0 ldi r18, 0x00 ; 0
118 90: 30 e0 ldi r19, 0x00 ; 0
119 92: 40 e8 ldi r20, 0x80 ; 128
<snip>
This seems to confirm that my size assumptions are correct.
I know nothing about IEEE float format, so I still need confirmation on my
assumption there.
Ted Roth
avr-gcc-list at http://avr1.org
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-gcc-list] float sizes,
Theodore A. Roth <=