Code:
1)   .nolist
2)   #include "ti83plus.inc"
3)   #define    ProgStart    $9D95
4)   .list
5)   .org    ProgStart - 2
6)   .db    t2ByteTok, tAsmCmp
7)   b_call(_ClrLCDFull)
8)   ld    hl, 0
9)   ld    (PenCol), hl
10) ld    hl, msg
11) b_call(_PutS)            ; Display the text
12) b_call(_NewLine)
13) ret

14) msg:
15)   .db "Hello world!", 0
16) .end


This is an ASM hello world program. I'd like to have some things explained about it so I can understand it better. I've added line numbers to make it easier.

5) ".org ProgStart -2" What is .org and why must 2 be subtracted from the program's start location?

6) ".db t2ByteTok, tAsmCmp" What does this line do?

9) "(PenCol)" PenCol wasn't defined in the program. Where is it located? Is it a keyword?

Thanks for helping me with this understanding part. It's much appreciated.
5) .org is the origin address. More specifically, it's the location in RAM where this program will be loaded. It means that the .db line will be at address $9D93, the bcall will be at $9D95, the ld hl,0 will be at $9D98, etc.
6) This is a .db (Data Byte) line. Two literal bytes will be inserted into the program, t2ByteTok (literal $BB) and tAsmCmp (literal $6D). These are defined in ti83plus.inc.
9) Also defined in ti83plus.inc. It's a named memory address, specifically the byte where the column number of text to be displayed is stored.
5) Would it be okay if we just defined ProgStart as $9D93 and avoided the subtraction or was it done like that for a reason?

6) What do t2ByteTok and tAsmCmp do exactly?

9) Ah, I see.
techboy6601 wrote:
5) Would it be okay if we just defined ProgStart as $9D93 and avoided the subtraction or was it done like that for a reason?

6) What do t2ByteTok and tAsmCmp do exactly?

9) Ah, I see.


That Hello World example it's wrong...it uses penCol and _PutS, which doesn't make sense. It should use curRow and _PutS, or penCol and _VPutS. The former is for the large font, and the latter is for the small, variable-width font (like what's on the graph screen).

As far as your questions:

You can use $9D93. The start of userMem is $9D95 (it's even defined that way) so by subtracting 2 in the source like that, it becomes a little more obvious that the reason you're doing that is because of t2ByteTok and tAsmCmp (it's just offsetting the fact that you need to include them in your 8XP, but they don't get copied to userMem when actually run by the OS).

Those two tokens are used by the OS to make sure your program is an assembly program. If they're there, it knows it's safe to copy everything that comes afterward to userMem and pass control to you. Otherwise it doesn't.

It's basically the same as the AsmPrgm token oncalc, when you hand-type assembly programs (such as AsmPrgm:C9 -- which just does "ret").
Ah, I see. Would it still work if you removed t2ByteTok and tAsmCmp?
techboy6601 wrote:
Ah, I see. Would it still work if you removed t2ByteTok and tAsmCmp?


No, your calculator would suddenly throw ERR:INVALID if you tried Asm(prgmWHATEVER (because you can't run programs without that using Asm( ).

It's also how shells know whether your program is BASIC or assembly.
Ah, I see!


Thanks for the help. I understand more things now.
You could also switch the two:
.db $BB,$6D
.org progstart ;without the -2

...but generally people write it the way you wrote it.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement