PDA

View Full Version : 8 Byte string



Jųan
- 13th February 2006, 01:06
The PB manual states that PB does not provide string capabilities with the exception of some commands.

What I'm trying to do is to declare an 8 byte string such as

$1E1E0C0C0C6C7C38

Then I would like to extract the 1st byte, send it to a device. Then extract the second byte and send it to another device and so on. At the moment I'm achieving this by doing:

for device = 1 to 8
gosub getbyteval
ShiftOut DOUt,clk,MSBFIRST,[device\8,ByteVal\8]
next

getByteVal: ' selects byte value according to device value
SELECT CASE device
CASE 1,2
byteval = $1E
CASE 3,4,5
byteval = $0C
CASE 6
byteval = $6C
CASE 7
byteval = $7C
CASE 8
byteval = $38
END SELECT
return

This works but the problem is that I have as many as 200 of these getByteVal subroutines to write. Is there a way to do this in less lines.
Maybe declare a string and extract its contents in the same line?

I've done ASM before. I seem to recall you could do some thing like this:

MOV DPTR,#FROMBLK

getByteVal: DB 1EH,1EH,0CH,0CH,0CH,6CH,7CH,38H


But Im rusty at it and need to brush up on it, I know there a few lines missing. If anyone can give me any pointers, it will be appreciated.

Juan

Bruce
- 13th February 2006, 02:38
See this thread on strings. http://www.picbasic.co.uk/forum/showthread.php?t=1999