Wilf Melling wrote: > I have made a start on my very first PIC project, it is to be a home > alarm system (hopefully). So here my very first plea for help, I > keep getting the following message. I have read the manuals but the > answer does not jump out at me. > > Message[302] C:\MPASM\HALARM.ASM 40 : Argument out of range. Least > significant bits used. > > Code sample with line numbers:- > 39 Movlw PORT_B_OUT ;Define PORTB > 40 Movwf TRISB ;as output > > PORT_B_OUT EQUates to b11111111 Wilf: This has nothing to do with your problem, but if you want all the PORTB pins to be outputs, PORT_B_OUT must equate to 00000000. Ok... The MPASM message refers not to PORT_B_OUT but to TRISB. If you look at the instruction set for your PIC, you'll see that register-oriented instructions only have room for 7-bit register addresses, so they can only address 128 registers. To accomodate more than 128 registers, PICs employ a banking scheme that uses a few bits of the STATUS register to select from multiple 128-register banks. If you try to directly access a register in any bank other than Bank 0, MPASM won't be able to fit the register's 8-bit address into the instruction. Instead, it'll just use the low 7 bits of the register's address and generate the message you're seeing. TRISB is located at address 086H, which puts it in Bank 1. To access it, you need to select bank 1 (by setting the RP0 bit in the STATUS register), then write to register 006H. Before accessing registers on Bank 0, you'll need to switch back to that page by clearing the RP0 bit. Your code should look like this: BSF STATUS,RP0 MOVLW PORT_B_OUT MOVWF 080H ^ TRISB BCF STATUS,RP0 The "080H ^ TRISB" exclusive-ORs the TRISB address with 080H, thereby clearing the high bit of the address... It's equivalent to "07FH & TRISB", "TRISB - 128", and "006H". -Andy Andrew Warren - fastfwd@ix.netcom.com Fast Forward Engineering, Vista, California http://www.geocities.com/SiliconValley/2499