----- Original Message ----- From: myke predko To: Sent: Wednesday, October 23, 2002 5:17 PM Subject: Re: [PIC]: String macro parameters > Olin, > > From your original reply, it sounded like you knew of a way to parse a > string and pass individual characters to specific statements in the format > that was originally asked: > > > > > > TEXT "Hello" > > > > and have it expand to: > > > > sublw 'H' > > > > sublw 'e' > > > > sublw 'l' > > > > sublw 'l' > > > > sublw 'o' > > > > << > > > > > > > > This can be done. > > A macro that can convert a parameter string to a DT statement is pretty > simple - I (and the original poster) was hoping for something a bit more > arbitrary. > > Thanx anyway, > > myke Depends on the assembler, in xcasm you could write Unoptimised foo .macro arg xlen .set STRLEN(arg) indx .set 0 .while indx < xlen sublw INT(SUBSTR(arg, indx, 1)) indx .set indx + 1 .done .endm Optimised foo .macro arg xlen .set STRLEN(arg) indx .set 0 xacc .set 0 .while indx < xlen xacc .set xacc + INT(SUBSTR(arg, indx, 1)) indx .set indx + 1 .done sublw xacc & $ff .endm Regards Sergio Masci -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu