gnupic: Questions about SDCC PIC code gen


Previous by date: 22 Oct 2002 04:22:05 -0000 Re: Questions about SDCC PIC code gen, matt
Next by date: 22 Oct 2002 04:22:05 -0000 Re: Questions about SDCC PIC code gen, matt
Previous in thread: 22 Oct 2002 04:22:05 -0000 Re: Questions about SDCC PIC code gen, matt
Next in thread: 22 Oct 2002 04:22:05 -0000 Re: Questions about SDCC PIC code gen, matt

Subject: Re: Questions about SDCC PIC code gen
From: Rick Mann ####@####.####
Date: 22 Oct 2002 04:22:05 -0000
Message-Id: <B9DA1EDC.E731%rmann@latencyzero.com>

on 10/21/02 7:27 PM, matt at ####@####.#### wrote:

> Can you give us, say, the 5 preceding assembly instructions and the 5
> following. Thanks.

Sure! I only limited it because it was on a different computer, and I was
typing it all in. Here's the actual code, copy/pasted. I've put both the C
and the ASM, but I left out all of the equates. BTW, I also don't get proper
code for setting the global gIRState variable.


-----------------------

#include "p16f877.h"


typedef    unsigned char            UInt8;


void InitPorts();


UInt8                gIRState    =    0;


void
main()
{
    InitPorts();
    PORTD = 0xA;
}

void
InitPorts()
{
    //    Clear GIE
    
    do
    {
        GIE = 0;
    } while (GIE != 0);
    
    TRISD = 0;
    
    //    Clear all our program registers
    
    gIRState = 1;
}

-----------------------

    ORG 0
;--------------------------------------------------------
; interrupt vector 
;--------------------------------------------------------
;    .area    CSEG    (CODE)
;__interrupt_vect:
;    ljmp    __sdcc_gsinit_startup
;    reti
;    .ds    7
;    reti
;    .ds    7
;    reti
;    .ds    7
;    reti
;    .ds    7
;    reti
;    .ds    7
;    reti
;    .ds    7
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
;    .area GSINIT  (CODE)
;    .area GSFINAL (CODE)
;    .area GSINIT  (CODE)
__sdcc_gsinit_startup:
;    .area GSFINAL (CODE)
;    ljmp    __sdcc_program_startup
;--------------------------------------------------------
; code
;--------------------------------------------------------
;    .area CSEG    (CODE)
;***
;  pBlock Stats: dbName = D
;***
;; Starting pCode block
;***
;  pBlock Stats: dbName = M
;***
;entry:  _main    ;Function start
; 2 exit points
;has an exit
;functions called:
;   _InitPorts
;   _InitPorts
;; Starting pCode block
_main    ;Function start
; 2 exit points
;#CSRC    test.c 16
;  InitPorts();
    CALL    _InitPorts
;#CSRC    test.c 17
;  PORTD = 0xA;
    MOVLW    0x0a
    MOVWF    _PORTD
    RETURN    
; exit point of _main
;***
;  pBlock Stats: dbName = C
;***
;entry:  _InitPorts    ;Function start
; 2 exit points
;has an exit
;; Starting pCode block
_InitPorts    ;Function start
; 2 exit points
;#CSRC    test.c 27
;  GIE = 0;
    BCF    (_GIE >> 3), (_GIE & 7)
    BSF    _STATUS,5
;#CSRC    test.c 30
;  TRISD = 0;
    CLRF    _TRISD
;#CSRC    test.c 34
;  gIRState = 1;
    MOVLW    0x01
    BCF    _STATUS,5
    RETURN    
; exit point of _InitPorts
    end


-- 
Rick


Previous by date: 22 Oct 2002 04:22:05 -0000 Re: Questions about SDCC PIC code gen, matt
Next by date: 22 Oct 2002 04:22:05 -0000 Re: Questions about SDCC PIC code gen, matt
Previous in thread: 22 Oct 2002 04:22:05 -0000 Re: Questions about SDCC PIC code gen, matt
Next in thread: 22 Oct 2002 04:22:05 -0000 Re: Questions about SDCC PIC code gen, matt


Powered by ezmlm-browse 0.20.