=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Date: Fri, 21 Apr 2000 06:53:31 From: Nikolai Golovchenko <golovchenko-at-mail.ru> To: pic microcontroller discussion list <PICLIST-at-MITVMA.MIT.EDU> Subject: Re: Piclist, code generator by Nikolai Golovchenko, delimiters ? -------------------------------------------------------------------------------- Hi Kübek, Thanks for your response. I did thought about how let users specify delimiters, but I was reluctant to do so since no one asked :) Check out the page in a couple of days. Comments below. Bye, Nikolai On Thursday, April 20, 2000 Kübek Tony wrote: > Hi ( Nikolai in particular ), > I'm a bit confused about one part of the generated code, > tried to follow it but think I failed. As far as I can tell > there is no way to specify the delimiters one wants when > requesting code to be generated ? > It seems like the delimiter check always will end up like: > parse_state_delimiter > ;called from state table to check for end of name > movwf parse_state > movfw parse_char ; w = X > skpnz > retlw 0 ; W==0 -> X == 0 Here it checks if this is the end of a zero terminated string. Useful when reading characters from a string. > addlw -' ' ; in MPASM = ADDLW 0xE0 ; w = x+0xE0 > skpnz > retlw 0 ; W==0 -> X == 0x1F ? Checks if the character is space, which is regarded as a delimiter. -' ' gets translated into 256 - ' '. So if character is space, you get 256 - ' ' + ' ', which is zero. Just a universal and clear :) way to check bytes for equality. You can see this everywhere in the generated code. For example, if I wanted to test accumulator for say 'a' and 'b', it would look like addlw -'a' ;substract 'a' from accumulator skpnz retlw 1 ;w == 'a' addlw 'a' ;restore accumulator addlw -'b' skpnz retlw 2 ;w == 'b' Or a bit shorter, addlw -'a' ;substract 'a' from accumulator skpnz retlw 1 ;w == 'a' addlw 'a' - 'b' ;restore accumulator and substract 'b' skpnz retlw 2 ;w == 'b' > addlw ' ' - '\t' ; in MPASM = ADDLW 0x17 ; w = X+0xE0+0x17 > skpnz > retlw 0 ; W==0 -> X == 0x08 ? Is it tab? > addlw '\t' - '(' ; in MPASM = ADDLW 0xE1 ; w = > X+0xE0+0x17+0xE1 > skpnz > retlw 0 ; W==0 -> X == 0x27 ? > retlw 255 Is it '('? If not '(' then return error (w=255). May be useful if keywords are functions like WriteEE(14, 1). > Which I 'think' means the following: > Delimiters 'accepted' ( return with w=0 ) are: > 1 - 0x00 = 'NULL', this one is ok by me > 2 - 0x1F = 'US' ,??? > 3 - 0x08 = 'BS' ,??? > 4 - 0x27 = ''' , ??? It is '\0', ' ', '\t', and ')'. > All else will 'fail' and return with 255 in w > ( there are no comments on these lines, so it's a bit hard to tell what > they do ) > ( and I'm guessing that used radix could affect the result ) Yes, radix affects the result. I always assume decimal radix. It would be easy though to replace 255 and such with 0xFF. > What am i getting wrong with this, I dont understand any > of these delimiters accept the 'NULL' one. Why choosing > such strange characters ? ( or, which I think, my 'guessing' is wrong ). > Wouldn't it be more 'logical' to use 0x0D 'CR', 0x0A 'LF' or 0x0x03 > 'ETX' ? I'll change the form to include any delimiters you wish, but they must be one byte long. So if you want to skip newline (0x0D, 0x0A), specify 0x0D as a delimiter, and 0x0a as a whitespace. > /Tony > PS Many thanks to Nikolai Golovchenko, excellent code generator DS > Tony Kübek, Flintab AB > ²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² > E-mail: tony.kubek-at-flintab.com > ²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²