DEBUGIN to get a letter to use as name of DATA block
John Kauffman
Posts: 653
I want to get from the user a letter and use that letter to identify the appropriate data block.
I have a data block associated with each letter of the alphabet as follows:
A DATA 0,0,0,0,0
B DATA 0,0,0,0,1
C DATA 0,0,0,1,0
...
I have written:
DEBUGIN myLetter
for counter = 0 to 4
READ myLetter+counter, myBit
debug myBit
next
For DEBUGIN value of "B" I should see 00001 but instead get a string for which I can't see a pattern. I think I am misunderstanding the value returned from DEBUGIN when the user types a non-numeric value.
Any thoughts? Thanks.
I have a data block associated with each letter of the alphabet as follows:
A DATA 0,0,0,0,0
B DATA 0,0,0,0,1
C DATA 0,0,0,1,0
...
I have written:
DEBUGIN myLetter
for counter = 0 to 4
READ myLetter+counter, myBit
debug myBit
next
For DEBUGIN value of "B" I should see 00001 but instead get a string for which I can't see a pattern. I think I am misunderstanding the value returned from DEBUGIN when the user types a non-numeric value.
Any thoughts? Thanks.
Comments
The labels A, B, C, etc. have values that is the address of the memory location at the time the statement is compiled. Assuming that the statement labelled A is the first in the program, the label A has the value 0. The label B has the value 5, and the label C has the value 10 ... all because there are 5 bytes produced by each DATA statement.
The DEBUGIN statement takes the entered letter and stores it in myLetter as the number equivalent in ASCII to the letter. For the capital letters, "A" becomes 65, "B" becomes 66, and "C" becomes 67.
If you still want to use the capital letters and each entry has 5 bytes, you could use:
READ (myLetter-"A")*5+counter,myBit
DEBUG DEC myBit
Note that, if you enter an invalid character, the READ will use an invalid memory location. Remember that myBit is a number, not an ASCII digit. You need the DEC (or HEX or BIN) formatter to display it properly.
Mike: You are right, my model was not accurate.
Now that I understand what is happening, a far easier solution has become clear. Much thansk, guys,