AVR-GCC a pointer na funkci

Petr Tomasek tomasek@etf.cuni.cz
Úterý Leden 1 20:02:37 CET 2008


> 
> Nadefinovani reply_gen jako "volatile void (*reply_gen)(void)" 
> vygeneruje spoustu varovani o nekompatibilite typu a stale je v kodu 
> vynecha. Tak nevim.
> 
> Kompletni soubory jsou v priloze.


Verze gcc?

Me to prelozilo bez kecu:

   [tomasek@************]$ make
   avr-gcc -g -mmcu=atmega8 -Wall -Wstrict-prototypes -Os -mcall-prologues -Os -c main.c
   avr-gcc -g -mmcu=atmega8 -Wall -Wstrict-prototypes -Os -mcall-prologues -o main.out -Wl,-Map,main.map main.o 
   avr-objcopy -R .eeprom -O ihex main.out main.hex 

...akorat se mi nechtelo hledat pro ktery MCU to je, tak jsem zakomentoval inicializaci
timeru/PWM. Prikladam vypis assembleru...

P.T.

-- 
Petr Tomasek <http://www.etf.cuni.cz/~tomasek>
Jabber: butrus@jabbim.cz
SIP: butrus@ekiga.net
-------------- next part --------------
	.file	"main.c"
	.arch atmega8
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
	.global __do_copy_data
	.global __do_clear_bss
	.section	.debug_abbrev,"",@progbits
.Ldebug_abbrev0:
	.section	.debug_info,"",@progbits
.Ldebug_info0:
	.section	.debug_line,"",@progbits
.Ldebug_line0:
	.text
.Ltext0:
.global	rep1
	.type	rep1, @function
rep1:
.LFB3:
.LM1:
/* prologue: frame size=0 */
/* prologue end (size=0) */
.LM2:
	sbi 56-0x20,1
/* epilogue: frame size=0 */
	ret
/* epilogue end (size=1) */
/* function rep1 size 2 (1) */
.LFE3:
	.size	rep1, .-rep1
.global	rep2
	.type	rep2, @function
rep2:
.LFB4:
.LM3:
/* prologue: frame size=0 */
/* prologue end (size=0) */
.LM4:
	cbi 56-0x20,1
/* epilogue: frame size=0 */
	ret
/* epilogue end (size=1) */
/* function rep2 size 2 (1) */
.LFE4:
	.size	rep2, .-rep2
.global	SIG_OUTPUT_COMPARE0A
	.type	SIG_OUTPUT_COMPARE0A, @function
SIG_OUTPUT_COMPARE0A:
.LFB5:
.LM5:
/* prologue: frame size=0 */
	push __zero_reg__
	push __tmp_reg__
	in __tmp_reg__,__SREG__
	push __tmp_reg__
	clr __zero_reg__
	push r18
	push r19
	push r20
	push r21
	push r22
	push r23
	push r24
	push r25
	push r26
	push r27
	push r30
	push r31
/* prologue end (size=17) */
.LM6:
	lds r30,reply_gen
	lds r31,(reply_gen)+1
	icall
/* epilogue: frame size=0 */
	pop r31
	pop r30
	pop r27
	pop r26
	pop r25
	pop r24
	pop r23
	pop r22
	pop r21
	pop r20
	pop r19
	pop r18
	pop __tmp_reg__
	out __SREG__,__tmp_reg__
	pop __tmp_reg__
	pop __zero_reg__
	reti
/* epilogue end (size=17) */
/* function SIG_OUTPUT_COMPARE0A size 39 (5) */
.LFE5:
	.size	SIG_OUTPUT_COMPARE0A, .-SIG_OUTPUT_COMPARE0A
.global	main
	.type	main, @function
main:
.LFB6:
.LM7:
/* prologue: frame size=0 */
	ldi r28,lo8(__stack - 0)
	ldi r29,hi8(__stack - 0)
	out __SP_H__,r29
	out __SP_L__,r28
/* prologue end (size=4) */
.LM8:
	out 56-0x20,__zero_reg__
.LM9:
	ldi r24,lo8(2)
	out 55-0x20,r24
.LM10:
	ldi r24,lo8(pm(rep1))
	ldi r25,hi8(pm(rep1))
	sts (reply_gen)+1,r25
	sts reply_gen,r24
.LM11:
/* #APP */
	sei
/* #NOAPP */
.L5:
.LM12:
	in r24,54-0x20
	rjmp .L5
/* epilogue: frame size=0 */
/* epilogue: noreturn */
/* epilogue end (size=0) */
/* function main size 17 (13) */
.LFE6:
	.size	main, .-main
	.comm reply_gen,2,1
.Letext0:
	.section	.debug_line
	.long	.LELT0-.LSLT0

.LSLT0:
	.word	2

	.long	.LELTP0-.LASLTP0

.LASLTP0:
	.byte	0x1
	.byte	0x1
	.byte	0xf6
	.byte	0xf5
	.byte	0xa
	.byte	0x0
	.byte	0x1
	.byte	0x1
	.byte	0x1
	.byte	0x1
	.byte	0x0
	.byte	0x0
	.byte	0x0
	.byte	0x1
	.ascii	"/usr/bin/../lib/gcc/avr/3.4.6/../../../../avr/include"
	.byte	0
	.ascii	"/usr/bin/../lib/gcc/avr/3.4.6/include"
	.byte	0
	.byte	0x0
	.string	"stdint.h"
	.uleb128 0x1
	.uleb128 0x0
	.uleb128 0x0
	.string	"inttypes.h"
	.uleb128 0x1
	.uleb128 0x0
	.uleb128 0x0
	.string	"stddef.h"
	.uleb128 0x2
	.uleb128 0x0
	.uleb128 0x0
	.string	"stdlib.h"
	.uleb128 0x1
	.uleb128 0x0
	.uleb128 0x0
	.string	"main.c"
	.uleb128 0x0
	.uleb128 0x0
	.uleb128 0x0
	.byte	0x0
.LELTP0:
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM1

	.byte	0x4
	.uleb128 0x5
	.byte	0x1f
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM2

	.byte	0x15
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM3

	.byte	0x18
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM4

	.byte	0x15
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM5

	.byte	0x18
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM6

	.byte	0x15
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM7

	.byte	0x1c
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM8

	.byte	0x16
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM9

	.byte	0x15
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM10

	.byte	0x1d
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM11

	.byte	0x16
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.LM12

	.byte	0x18
	.byte	0x0
	.uleb128 0x3
	.byte	0x2
	.word	.Letext0

	.byte	0x0
	.uleb128 0x1
	.byte	0x1
.LELT0:
	.section	.debug_info
	.long	202

	.word	2

	.long	.Ldebug_abbrev0

	.byte	0x2
	.uleb128 0x1
	.long	.Ldebug_line0

	.word	.Letext0

	.word	.Ltext0

	.long	.LASF11

	.byte	0x1
	.long	.LASF12

	.long	.LASF13

	.uleb128 0x2
	.long	.LASF0

	.byte	0x1
	.byte	0x6
	.uleb128 0x2
	.long	.LASF1

	.byte	0x1
	.byte	0x8
	.uleb128 0x3
	.string	"int"
	.byte	0x2
	.byte	0x5
	.uleb128 0x2
	.long	.LASF2

	.byte	0x2
	.byte	0x7
	.uleb128 0x2
	.long	.LASF3

	.byte	0x4
	.byte	0x5
	.uleb128 0x2
	.long	.LASF4

	.byte	0x4
	.byte	0x7
	.uleb128 0x2
	.long	.LASF5

	.byte	0x8
	.byte	0x5
	.uleb128 0x2
	.long	.LASF6

	.byte	0x8
	.byte	0x7
	.uleb128 0x4
	.byte	0x1
	.long	.LASF7

	.byte	0x5
	.byte	0xc
	.byte	0x1
	.word	.LFB3

	.word	.LFE3

	.byte	0x8
	.byte	0x90
	.uleb128 0x20
	.byte	0x93
	.uleb128 0x1
	.byte	0x90
	.uleb128 0x21
	.byte	0x93
	.uleb128 0x1
	.uleb128 0x4
	.byte	0x1
	.long	.LASF8

	.byte	0x5
	.byte	0x11
	.byte	0x1
	.word	.LFB4

	.word	.LFE4

	.byte	0x8
	.byte	0x90
	.uleb128 0x20
	.byte	0x93
	.uleb128 0x1
	.byte	0x90
	.uleb128 0x21
	.byte	0x93
	.uleb128 0x1
	.uleb128 0x4
	.byte	0x1
	.long	.LASF9

	.byte	0x5
	.byte	0x16
	.byte	0x1
	.word	.LFB5

	.word	.LFE5

	.byte	0x8
	.byte	0x90
	.uleb128 0x20
	.byte	0x93
	.uleb128 0x1
	.byte	0x90
	.uleb128 0x21
	.byte	0x93
	.uleb128 0x1
	.uleb128 0x5
	.byte	0x1
	.long	.LASF10

	.byte	0x5
	.byte	0x1f
	.byte	0x1
	.long	47

	.word	.LFB6

	.word	.LFE6

	.byte	0x8
	.byte	0x90
	.uleb128 0x20
	.byte	0x93
	.uleb128 0x1
	.byte	0x90
	.uleb128 0x21
	.byte	0x93
	.uleb128 0x1
	.uleb128 0x6
	.byte	0x1
	.uleb128 0x7
	.long	.LASF14

	.byte	0x5
	.byte	0x8
	.long	199

	.byte	0x1
	.byte	0x3
	.byte	0x3
	.word	reply_gen

	.uleb128 0x8
	.byte	0x2
	.long	181

	.byte	0x0
	.section	.debug_abbrev
	.uleb128 0x1
	.uleb128 0x11
	.byte	0x1
	.uleb128 0x10
	.uleb128 0x6
	.uleb128 0x12
	.uleb128 0x1
	.uleb128 0x11
	.uleb128 0x1
	.uleb128 0x25
	.uleb128 0xe
	.uleb128 0x13
	.uleb128 0xb
	.uleb128 0x3
	.uleb128 0xe
	.uleb128 0x1b
	.uleb128 0xe
	.byte	0x0
	.byte	0x0
	.uleb128 0x2
	.uleb128 0x24
	.byte	0x0
	.uleb128 0x3
	.uleb128 0xe
	.uleb128 0xb
	.uleb128 0xb
	.uleb128 0x3e
	.uleb128 0xb
	.byte	0x0
	.byte	0x0
	.uleb128 0x3
	.uleb128 0x24
	.byte	0x0
	.uleb128 0x3
	.uleb128 0x8
	.uleb128 0xb
	.uleb128 0xb
	.uleb128 0x3e
	.uleb128 0xb
	.byte	0x0
	.byte	0x0
	.uleb128 0x4
	.uleb128 0x2e
	.byte	0x0
	.uleb128 0x3f
	.uleb128 0xc
	.uleb128 0x3
	.uleb128 0xe
	.uleb128 0x3a
	.uleb128 0xb
	.uleb128 0x3b
	.uleb128 0xb
	.uleb128 0x27
	.uleb128 0xc
	.uleb128 0x11
	.uleb128 0x1
	.uleb128 0x12
	.uleb128 0x1
	.uleb128 0x40
	.uleb128 0xa
	.byte	0x0
	.byte	0x0
	.uleb128 0x5
	.uleb128 0x2e
	.byte	0x0
	.uleb128 0x3f
	.uleb128 0xc
	.uleb128 0x3
	.uleb128 0xe
	.uleb128 0x3a
	.uleb128 0xb
	.uleb128 0x3b
	.uleb128 0xb
	.uleb128 0x27
	.uleb128 0xc
	.uleb128 0x49
	.uleb128 0x13
	.uleb128 0x11
	.uleb128 0x1
	.uleb128 0x12
	.uleb128 0x1
	.uleb128 0x40
	.uleb128 0xa
	.byte	0x0
	.byte	0x0
	.uleb128 0x6
	.uleb128 0x15
	.byte	0x0
	.uleb128 0x27
	.uleb128 0xc
	.byte	0x0
	.byte	0x0
	.uleb128 0x7
	.uleb128 0x34
	.byte	0x0
	.uleb128 0x3
	.uleb128 0xe
	.uleb128 0x3a
	.uleb128 0xb
	.uleb128 0x3b
	.uleb128 0xb
	.uleb128 0x49
	.uleb128 0x13
	.uleb128 0x3f
	.uleb128 0xc
	.uleb128 0x2
	.uleb128 0xa
	.byte	0x0
	.byte	0x0
	.uleb128 0x8
	.uleb128 0xf
	.byte	0x0
	.uleb128 0xb
	.uleb128 0xb
	.uleb128 0x49
	.uleb128 0x13
	.byte	0x0
	.byte	0x0
	.byte	0x0
	.section	.debug_pubnames,"",@progbits
	.long	80

	.word	2

	.long	.Ldebug_info0

	.long	206

	.long	89

	.string	"rep1"
	.long	111

	.string	"rep2"
	.long	133

	.string	"SIG_OUTPUT_COMPARE0A"
	.long	155

	.string	"main"
	.long	183

	.string	"reply_gen"
	.long	0

	.section	.debug_aranges,"",@progbits
	.long	16

	.word	2

	.long	.Ldebug_info0

	.byte	0x2
	.byte	0x0
	.word	.Ltext0

	.word	.Letext0-.Ltext0

	.word	0

	.word	0

	.section	.debug_str,"MS",@progbits,1
.LASF8:
	.string	"rep2"
.LASF13:
	.string	"/home/tomasek/c/avr/testing/mega8/simple"
.LASF7:
	.string	"rep1"
.LASF1:
	.string	"unsigned char"
.LASF9:
	.string	"SIG_OUTPUT_COMPARE0A"
.LASF4:
	.string	"long unsigned int"
.LASF10:
	.string	"main"
.LASF11:
	.string	"GNU C 3.4.6"
.LASF2:
	.string	"unsigned int"
.LASF6:
	.string	"long long unsigned int"
.LASF5:
	.string	"long long int"
.LASF14:
	.string	"reply_gen"
.LASF3:
	.string	"long int"
.LASF0:
	.string	"signed char"
.LASF12:
	.string	"main.c"
/* File "main.c": code   60 = 0x003c (  20), prologues  21, epilogues  19 */


Další informace o konferenci Hw-list