Hi list, I am trying my hand at relocatable code (using assembler for 16F628 and 16F877 parts), but I fell into a bit of a blind hole... The project worked perfectly the first time out (which I must admit is quite strange, as it is my first attempt at driving anything more complex than a transistor...), and it is basically a PIC writing a message to a 16x2 character LCD display. The code is structured in three files: delay.o -> contains various delay subs, which are totally independent from the main program lcd.o -> contains the LCD subs main.o -> contains the main program flow, what I want to display, etc. At first I statically set the port and bits to control the LCD inside lcd.o, but afterwards I decided that the whole point of using relocatable code is to be able to port it to other projects as easily as possible... So, from then on, I used six variables in the lcd.o object file which would be defined in the main.o file. (the idea behind this is to be able to change the ports and bits used by the LCD, depending on the complexity or needs of the project.) So I defined: LCTRL -> The port which has the LCD control lines (RS, RW, EN) LBUS -> The port which holds the LCD data/address LBUST -> LBUS direction control (LBUS's TRIS register) RS -> Bit n: for the RS line RW -> Bit n: for the RW line EN -> Bit n: for the EN line. The problem is that I can assign the registers in main.o, but not the bits!! For example: LPORTS UDATA 0x05 LCTRL RES 1 ; Set LCTRL as PORTA LBUS RES 1 ; Set LBUS as PORTB LTRIS UDATA 0x86 LBUST RES 1 ; Set LBUST as TRISB and afterwards I set them global.... no problem there.... but I still haven't found a way to specify the three control bits in the main file, and getting them to be global! Can anyone give me a clue, or is the only way to do it to use a mask (like, if I want EN to be bit 2, I set a register as EN and I set it's 2nd bit, so if I want to " bsf LCTRL,EN " instead I do: movlw 0xFF andwf EN,W iorwf LCTRL That would eventually get the job done, but it's 3 times as long, and not very "neat", shall we say, right? I'm very sorry to take up your time, but I couldn't find the answer anywhere, and I've been at this for about three days, trying all the different combinations I could think of... If anyone can shed some light, I'd greatly appreciate it. Thank you all very much, Ricardo Medina -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body