Ralph Landry wrote: >Hello, >Is there any way to test an argument in a Macro? If I have a constant >it works fine ie. > >test macro char > if(char > 0x7f) || (char <0x20) > movlw 0x20 > else > nop > endif > endm >... >... >... >If I then envoke > test 0x81 >it will will return a 0x20, just what I want, but I'd like to pass a >variable to it to test. I want to make sure that a certain area of >E2prom is between 20h and 7fh and if not to force the character to a >20h > >But I can't seem to pass an argument to the macro with local, variable, >set, it would be so much easier to be able to do some IF statement >testing instead of bit bashing STATUS. Is there any hope?? No. The IF statement is done at compiler (or assemble) time, it cannot deal with run-time data, such as what is stored in a register. AssureAscii macro ; Assure W is ascii code, else covert to space. addlw -0x20 ; convert to range of 0..5Fh. addlw 0x20-0x7F-1 ; shift all valid values negative, borrow. skpnc ; skip if borrow, (not carry) movlw ' '-0x7F-1 ; load a blank, modified with adjustments. addlw 0x7F+1 ; adjust back to correct range. endm ; done. The above macro should do what you were trying do do. From your problem statement I assumed that you are checking for valid ASCII characters so I labeled it as such. The first statement will shift the input range down to 0..5Fh. This is done to allow a simple single test for a valid range. Note that values under the desired range become large positive numbers. For example a 0x0D will become 0xED. The next statement shifts all valid numbers in your range to below 0 (0x80 will become zero.) A borrow is set if the value becomes zero, on the PIC borrow is the complement of carry. The next statement is a skip if no carry, or skip if borrow occurred. This skips the movlw if the value was in the correct range. The movlw loads a space, however what is in W needs to be adjusted back into the correct range, so that adjustment is provided to the space. The last statement adjusts the value back to the input range. (Note: above code is untested.) Now that you know how to accomplish what you were trying to do, I have to ask is that really what you want? Are you just reading and using data from your EEPROM, or are you trying to scan and repair the EEPROM data? If you want to scan and repair you really want a range test so you can skip rewriting the EEPROM if the data is correct. Also are you sure you don't have any control codes like carriage returns and line feeds? Good Luck, Chip Weller