Hello, Some time ago I wrote an Insertion sort algorithm for Mid-range PICs and=20 today decided to optimize it as much as possible. For this I need to=20 load the negative value of an address of a variable. Using 'movlw 0 -=20 var' or 'addlw 0 - var', where var is a file register is not accepted by=20 MPASM, and 'Error[151] : Operand contains unresolvable labels or is too=20 complex' is issued. Currently I found 2 workarounds - one needs an extra instruction to=20 convert the loaded address to a negative number, and the other defines=20 an absolute address of 'var' in RAM and then a precalculated negative=20 value of that address is used in the code. Both of these do not seem right, so I'm searching for a trick to negate=20 the address of 'var' in the preprocessor, without triggering an error. A part of my code to serve as an example follows. samp_array res N ; an array with N samples to be sorted ofst res 1 ; Offset in samp_array =3D current sample address ; - first sample address . . incf fsr_copy, w movwf fsr_copy movwf FSR addlw 0 - samp_array ; MPASM DOESN'T AGREE WITH THIS EXPRESSION movwf ofst ; offset =3D - (first_smp_adrs - cur_smp_adrs) ; =3D - first_smp_adrs + cur_smp_adrs This is the first workaround, which adds an extra instruction: incf fsr_copy, w movwf fsr_copy movwf FSR ; At this point W holds the address of the current sample ; Now an offset from the beginning of samp_array must be ; calculated and then stored in ofst. sublw samp_array ; Calculate the offset (first sample address - ; current sample addres). ; The result is a negative number. clrf ofst ; AN EXTRA INSTRUCTION IS ADDED subwf ofst, f ; (0 - offset) the offset is now positive. I'd gladly share the complete Insertion sort code, if anyone is interested. Regards, Svetlin --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .