DAT block questions.
Rontopia
Posts: 139
Im at the end of the objects lab and I just keep going over and over it and im really missing something about the dat block.
heres the code if from the objects lab and works just fine. but I have questions about how it works and .. well here's the code
[noparse][[/noparse]code]
''Top File: TestMessages.spin
''sent text messages sorted in DAT block to the hyper terminal.
Con
······· _clkmode = xtal1 + pll16x
······· _xinfreq = 5_000_000
OBJ
······· Debug: "FullDuplexSerialPlus"
PUB· TestDatMessages | value, counter
· ''send messages stored in the DAT Block.
Debug.start(31, 30, 0, 57600)
waitcnt(clkfreq*3 + cnt)
··· repeat
······· Debug.Str(@MyString)
······· Debug.Dec(counter++)
······· Debug.Str(@MyOtherString)
······· Debug.Str(@CR)
······· waitcnt(clkfreq + cnt)
DAT
MyString··················byte··· 10, 13, "This is a test message number: ", 0
MyOtherString·········· byte··· ", ", 10, 13, "and this is another line of text.",0
CR··························byte··· 10, 13, 0
·[noparse][[/noparse]/code]
so my question is.. why the byte? does this code use a byte per letter? or does it put as many letters in the byte as will fit? and relaly I dont understand why i even need a byte? if its a dat block, why isnt it just stuffed into memory untill needed? or is byte = to MyString? im lost and the lab really doesnt explain this well. at least I didnt get it. also where is the byte? is it main ram? or is it in cog ram?
also.. the 10 and the 13 .. 10 means indent 10 spaces? but then there is a 13 which mean carrage return, woldnt that carrage return send the curser back to the left hand side of the text window?
why do I need a counter variable? or what ever its called.. counter space, why am i counting every time this thing loops? or is that what its doing? why do i care how many times it loops? actually now that I think about it.. what is value doing?
ok I have more questions about it but I think this is enough for now. Im starting to think that I will never get this in my head.
ok.. one more and it more of a compile question. so in this code we are using FullDuplesSerialPlus. but we are only really using the Str method in that object right? so the compiler does not "cherry pick" that method form the object or the methods it needs, it compiles the whole object right? if that is so.. wouldnt it be better to make an object with just the Str method in it to save ram space? or is that a loaded question?
thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
IC layout designer
Austin Texas
heres the code if from the objects lab and works just fine. but I have questions about how it works and .. well here's the code
[noparse][[/noparse]code]
''Top File: TestMessages.spin
''sent text messages sorted in DAT block to the hyper terminal.
Con
······· _clkmode = xtal1 + pll16x
······· _xinfreq = 5_000_000
OBJ
······· Debug: "FullDuplexSerialPlus"
PUB· TestDatMessages | value, counter
· ''send messages stored in the DAT Block.
Debug.start(31, 30, 0, 57600)
waitcnt(clkfreq*3 + cnt)
··· repeat
······· Debug.Str(@MyString)
······· Debug.Dec(counter++)
······· Debug.Str(@MyOtherString)
······· Debug.Str(@CR)
······· waitcnt(clkfreq + cnt)
DAT
MyString··················byte··· 10, 13, "This is a test message number: ", 0
MyOtherString·········· byte··· ", ", 10, 13, "and this is another line of text.",0
CR··························byte··· 10, 13, 0
·[noparse][[/noparse]/code]
so my question is.. why the byte? does this code use a byte per letter? or does it put as many letters in the byte as will fit? and relaly I dont understand why i even need a byte? if its a dat block, why isnt it just stuffed into memory untill needed? or is byte = to MyString? im lost and the lab really doesnt explain this well. at least I didnt get it. also where is the byte? is it main ram? or is it in cog ram?
also.. the 10 and the 13 .. 10 means indent 10 spaces? but then there is a 13 which mean carrage return, woldnt that carrage return send the curser back to the left hand side of the text window?
why do I need a counter variable? or what ever its called.. counter space, why am i counting every time this thing loops? or is that what its doing? why do i care how many times it loops? actually now that I think about it.. what is value doing?
ok I have more questions about it but I think this is enough for now. Im starting to think that I will never get this in my head.
ok.. one more and it more of a compile question. so in this code we are using FullDuplesSerialPlus. but we are only really using the Str method in that object right? so the compiler does not "cherry pick" that method form the object or the methods it needs, it compiles the whole object right? if that is so.. wouldnt it be better to make an object with just the Str method in it to save ram space? or is that a loaded question?
thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
IC layout designer
Austin Texas
Comments
1. In standard ASCII codes, a byte is used to store a letter. In the ASCII code set, that byte can also hold various control and special characters. It is stuffed by the byte/word/long prefix. MyString is just a label for easy referencing later on. More info on ASCII here. The data is located in main ram.
2. 10 and 13 are the decimal equivalent of ASCII control characters. 10 is a Line Feed, which moves the cursor down one line at the place it is currently located. 13 is a Carriage Return, which moves the cursor to the start of the line it is on.
3. The value variable does not appear to be doing anything. The counter variable is to hold the number to output to the screen. It loops indefinitely. Every time it loops, it outputs the first message, outputs the counter variable, increments it (counter++), displays the second message, and outputs a carriage return sequence.
4. The reason for not creating an object with only what one needs is because it would probably be very time-consuming to do. Methods inside objects are usually highly dependent on each other to function, and if methods are missing, it would fail to compile. Also, making a custom object to save space rather than standard objects probably would not save much space, and it would be hard to find the modified version if it is not included.
I hope I could help. Feel free to ask me anymore questions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1010, so be surprised!
2 thats cool only in my mind this line:
MyString··················byte··· 10, 13, "This is a test message number: ", 0
would look like this:
MyString··················byte··· 10, "This is a test message number: ", 13, 0
or why do i need the CR at all if im asking for a new line with the "10".. does new line not mean what I think it does.." give me a new line to do something with" or is the CR telling the compiler where the new line is to start, which is below this one?
3.... oh duh.. ok i get it.·I think i get it.
so how do you use a variable in a DAT block? or can you I will give you an example of what I mean tho I know it would not work ..
this sort of thing would avoid confustion in my head as to where what CR and NL is and whats being displayed where... ikes I get lost easy and if everthing· was on its own line in code and then gets displayed that way.. you see what I mean? so I know what I wrote would not work but there should be a way for the variable counter to be included in the same line of code that it is to be displayed with. you know what Im saying? err writing?, getting at?
thanks for your help
and and if a byte is 8 bits.. and 101 0101 = T.. what happens to the blank? 101~0101..~ = blank .. its a memory cell and it has no blank state.. its either 1 or 0. is that 4th 1 or 0 just not read?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
IC layout designer
Austin Texas
Post Edited (Rontopia) : 3/8/2008 11:33:40 PM GMT
You pretty much have it. So different ASCII control codes are treated differently. 10 (newline), moves the cursor straight down one line. The code 13 (carraige return) moves the cursor all the way to the left but does not change which line it is on. So to position the cursor at the start of the next lower line, the sequence 10,13 will move the cursor down and then left. (or 13,10) which will move it left and then down, both put it in the same spot. If you have a string 10,"string", 13 then the cursor is left at the beginning of the line where the string is and if another string is printed it might over write the current string.
So in the code example the line:
Has a string which first moves the cursor down and left, then it prints the message, then it *leaves* the cursor just after the "x" (which is replaced by a number I suspect)
Clear?
--Chuck
so CR does not really mean CR like on a keyboard.. it just means "go all the way to the left from here"
I get it?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
IC layout designer
Austin Texas
Those all have "responses" by a printing/display device that are defined by ASCII. When you send them to a program (because you are typing on a keyboard) the program can choose to do whatever it wants with them.
--Chuck
on a typewriter, we can return the carriage, without going to a new line, hence chr 13 (0x0D)
now once the carriage is returned, we need to advance the paper up, or a new line, hence chr 10 (0xA)
hope the little history back in time thing shows where it came from.
CR byte 10, 13, 0 'use for a blank line.
This is a problem if you really want a Carriage Return without a line feed, say, to add underscores. (Which worked with printers)
thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
IC layout designer
Austin Texas