C nebo ASM?
Jan Waclawek
konfera@efton.sk
Čtvrtek Květen 21 15:47:51 CEST 2009
Inak pre porovnanie, toto mi vyplul nejaky nie najnovsi SDCC s -mpic16 (to "16" je "16-bit", t.j. PIC18xxx):
;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 2.7.4 #4932 (Oct 15 2007) (MINGW32)
; This file was generated Thu May 21 14:34:33 2009
;--------------------------------------------------------
; PIC16 port for the Microchip 16-bit core micros
;--------------------------------------------------------
list p=18f452
radix dec
;--------------------------------------------------------
; public variables in this module
;--------------------------------------------------------
global _Pom
global _Ukazatel
global _Bufer
global _p_Ukaz
global _main
;--------------------------------------------------------
; extern variables in this module
;--------------------------------------------------------
extern __gptrput1
;--------------------------------------------------------
; Equates to used internal registers
;--------------------------------------------------------
STATUS equ 0xfd8
FSR0L equ 0xfe9
FSR0H equ 0xfea
INDF0 equ 0xfef
POSTDEC1 equ 0xfe5
PRODL equ 0xff3
; Internal registers
.registers udata_ovr 0x0000
r0x00 res 1
r0x01 res 1
r0x02 res 1
r0x03 res 1
udata_u1_0 udata
_p_Ukaz res 3
udata_u1_1 udata
_Pom res 1
udata_u1_2 udata
_Ukazatel res 1
udata_u1_3 udata
_Bufer res 40
;--------------------------------------------------------
; interrupt vector
;--------------------------------------------------------
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
; I code from now on!
; ; Starting pCode block
S_u1__main code
_main:
; .line 7; u1.c p_Ukaz = &Bufer[0];
MOVLW HIGH(_Bufer)
BANKSEL (_p_Ukaz + 1)
MOVWF (_p_Ukaz + 1), B
MOVLW LOW(_Bufer)
BANKSEL _p_Ukaz
MOVWF _p_Ukaz, B
MOVLW 0x80
BANKSEL (_p_Ukaz + 2)
MOVWF (_p_Ukaz + 2), B
BANKSEL _Pom
; .line 9; u1.c Pom=0;
CLRF _Pom, B
; .line 10; u1.c for (Ukazatel=8;Ukazatel<32+8;++Ukazatel) {
MOVLW 0x08
BANKSEL _Ukazatel
MOVWF _Ukazatel, B
_00105_DS_:
MOVLW 0x28
BANKSEL _Ukazatel
SUBWF _Ukazatel, W, B
BTFSC STATUS, 0
GOTO _00109_DS_
; .line 11; u1.c Pom=Pom+Bufer[Ukazatel];
MOVLW LOW(_Bufer)
BANKSEL _Ukazatel
ADDWF _Ukazatel, W, B
MOVWF r0x00
CLRF r0x01
MOVLW HIGH(_Bufer)
ADDWFC r0x01, F
MOVFF r0x00, FSR0L
MOVFF r0x01, FSR0H
MOVFF INDF0, r0x00
MOVF r0x00, W
BANKSEL _Pom
ADDWF _Pom, F, B
; .line 12; u1.c *p_Ukaz++=Bufer[Ukazatel];
MOVFF _p_Ukaz, r0x01
MOVFF (_p_Ukaz + 1), r0x02
MOVFF (_p_Ukaz + 2), r0x03
MOVFF r0x00, POSTDEC1
MOVFF r0x01, FSR0L
MOVFF r0x02, PRODL
MOVF r0x03, W
CALL __gptrput1
BANKSEL _p_Ukaz
INCF _p_Ukaz, F, B
BTFSS STATUS, 0
BRA _10105_DS_
BANKSEL (_p_Ukaz + 1)
INCF (_p_Ukaz + 1), F, B
_10105_DS_:
BTFSS STATUS, 0
BRA _20106_DS_
BANKSEL (_p_Ukaz + 2)
INCF (_p_Ukaz + 2), F, B
_20106_DS_:
BANKSEL _Ukazatel
; .line 10; u1.c for (Ukazatel=8;Ukazatel<32+8;++Ukazatel) {
INCF _Ukazatel, F, B
GOTO _00105_DS_
_00109_DS_:
RETURN
; Statistics:
; code size: 132 (0x0084) bytes ( 0.10%)
; 66 (0x0042) words
; udata size: 45 (0x002d) bytes ( 3.52%)
; access size: 4 (0x0004) bytes
end
----- Original Message ---------------
>Puvodni zprava ze dne 21.5.2009 od Michal HW:
>
>> Divam se ne preklad Hitech C kompilatoru pro PIC18:
>> Pom=0;
>> for (Ukazatel=8;Ukazatel<32+8;++Ukazatel) {
>> Pom=Pom+Bufer[Ukazatel];
>> *p_Ukaz++=Bufer[Ukazatel];
>> }
>
Další informace o konferenci Hw-list