> I've been writing a fair bit of assembly over the last few weeks or so > and it's starting to look rather bad - not so much 'cos it doesn't work > as because it just looks messy - and therefore is hard for others to > figure out. So, is there a style guide out there that seems reasonably > standard (and concise !) like say, the Indian Hill style guide for C, > only for assembly ? > What are people using ? The following is a brief description of my personal taste; others' may vary. Labels: I haven't 100% settled on a convention here, though I tend to use 6-10 characters, lowercase, with underscores for code and data labels, and allcaps with underscores for Microchip-defined I/O definitions or const- ants, and LeadingCaps for custom I/O definitons. Other than data or constant definitions, I almost always put labels on a line by themself; this makes it much easier if I'm cutting and pasting a section of code whose first line includes a label and seems to pose no real disadvantage. The ",f" flag Generally left off most instructions, except that I always include it on "movf x,f". I'll also occasionally use it to make it especially clear that a particular instruction uses ",f" as the destination if it might otherwise be confusing. TRIS vs the TRISA/TRISB registers I personally tend to use the TRIS instructions; I'm hoping that Microchip will someday produce chips with the ability to access the TRIS registers redundantly in bank 0. Perhaps I should use the longer BSF RP0, etc. but I see no particular need. Also, I tend to prefer, e.g. movlw VRCON movwf FSR movlw whatever movwf INDF to movlw whatever bsf RP0 movwf VRCON ^ h'80' bcf RP0 Hexadecimal numbers The one proper format for hex numbers is $ABCD. Unfortunately, Microchip doesn't support that in their MPASM assembler. But maybe if people bug them enough they will [I don't think "$" is used for anything else]. I personally generally prefer ASPIC by Don Lekei [does anyone know if the address in the .DOC is current? I need to send him his shareware fee since I've increasingly decided I like ASPIC] which does accomodate the proper "$" notation. Conditional code Whenever I write a conditional instruction, I always indent the following instruction by one additional space. For example: clrf counter bsf counter,3 ; eight reps outloop: rrf data btfss C bsf Output ; inverted logic [nb: ASPIC allows bit labels] btfsc C bcf Output call delay decfsz counter goto outloop In cases where two conditionals are used in a row, the one-space rule still holds: movf srcL,w addwf destL,w movf srcM,w btfsc C incfsz srcM,w addwf dstM,w ; Indented one space, not two rlf KZ,w ; KZ = known-zero address addwf srcH,w addwf dstH Anyway, those are just some of how I do things (though I'm not really quite consistent with labeling conventions; if I'm working with existing code I try to follow its convetions and am likely to use them in the next new pro- ject I start).