Hi, MPASM is a bit rigorous (which I personally find as not so bad). In the code, the words LIST and INCLUDE are directives which should not begin on column 1. On the opposite, equated symbols (e. g. d1) are labels and as such should begin on column 1. BTW I prefer the way of assembly writing one builds up zones: 1. zone: Labels beginning on columns 1 2. zone: directive/instruction: begins on column 9 3. zone: operands (if any): begins on col. 17 4. zone: comment (if any): begins on col. 33 I think this way enhances the readibility of the code. Regards, Imre > ------------------------------------------- > > ;Setup > list P=16F877 > include "c:\P16F877.inc" > > ;Declarations > d1 equ 20 > d2 equ 21 > d3 equ 22 > org 0 > > Init movlw b'00000000' ;all porta low > movwf PORTA > bsf STATUS,RP0 ;bank 1 > bcf STATUS,RP1 > movlw b'11110000' ;0,1,2,3 of porta are output > movwf TRISA > bcf STATUS,RP0 ;bank 0 > retlw 0 > > Delay > ;4999993 cycles > movlw 0x2C > movwf d1 > movlw 0xE7 > movwf d2 > movlw 0x0B > movwf d3 > Delay_0 > decfsz d1, f > goto $+2 > decfsz d2, f > goto $+2 > decfsz d3, f > goto Delay_0 > > ;3 cycles > goto $+1 > nop > > ;4 cycles (including call) > return > > Start call Init > Main bcf PORTA,1 > bcf PORTA,2 > bcf PORTA,3 > bsf PORTA,0 > call Delay > bcf PORTA,0 > bsf PORTA,1 > call Delay > bcf PORTA,1 > bsf PORTA,2 > call Delay > bcf PORTA,2 > bsf PORTA,3 > call Delay > goto Main > End > > I don't know how most people write their programs, but a book i've read says to declare, then initialize, then other subroutines, then start, then main functions. Also, when i try to dry run this program in MPLAB, i get a stack underflow error, when it gets past the end of the Init subroutine. Any help would be greatly appreciated, and also any tips on laying out ASM code, structure. > > Thanks > -Peter > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics