I'm new to assembly programming, and I'm trying this example from the TI-83 Plus System Routines PDF, but it's not working.

It should create a string named "Str1" with a length of 100 bytes (I don't know how to specify the data though, can someone help me with that, too? =/)
But instead makes this string I can't access named "H".

Can anyone fix it?


Code:

.NOLIST
#define   EQU   .equ
#define   equ   .equ
#define   END   .end
#define   end   .end
#define   ProgStart   $9D95
#include "ti83plus.inc"
.LIST
    .org   ProgStart - 2
    .db    t2ByteTok, tAsmCmp

    ld     HL,Str1name
    rst    rMov9ToOP1
    ld     HL,100
    B_CALL(_CreateStrng)
    ret

Str1name:
    .db    StrngObj,tVarStrng,tStr1,0,0

.end
end


Thanks for any help!
this may or may not be causing it, but since you are moving 9 bytes to Op1, I would go ahead and pad Str1name with 9 bytes (you have 5, so add 4 more 0s)

After the call to createstrng HL will be pointing to the VAT entry (save this!) which will then contain a pointer in it to the data section (don't remember the VAT structure off the top of my head, but this should be easy to find out from learn z80 in 28 days or similar)
The code looks fine to me... and you only need to zero-terminate the string; padding it to 9 bytes is unnecessary.
Remember that because I'm new to this and still learning it... I have no clue what you're talking about.
Would anyone mind just fixing the code so it makes Str1 and gives it some data (anything), and showing me what the meaning of the fixes you made are?
Try this:

Code:

Str1name:
    .db    StrngObj,tVarStrng,tStr1,0,0,0,0,0

It might work, if your problem is garbage bytes getting moved to OP1 and TIOS using those in the VAT entry. This is what people meant when they said to pad Str1name out to nine bytes.
Ah! I got it.
I replaced that weird "rst" line with a "real" rom call:

Code:
B_CALL(_Mov9ToOP1)


Now how do I set the string's data?
KermMartian wrote:
The code looks fine to me... and you only need to zero-terminate the string; padding it to 9 bytes is unnecessary.


My thought was that it was reading past the end of the ASM program, and I didn't know how it would react to that....

as for the reading/writing data, this is all you need to do (this is after the create string bcall)


Code:
inc de
inc de ;skip past the size bytes
;de is now pointing at the location to start copying data
;start ld'ing it some info :)


for example...


Code:
inc de
inc de
ld a, tH
ld (de), a
inc de
ld a, tI
ld (de), a


or...


Code:
inc de
inc de
ld hl, str_val
ld bc, str_val_end - str_val
ldir
str_val:
  .db tH, tE, tL, tL, tO
str_val_end:
Okay... I've figured out how to set Str1. But now it's a real variable. And I can't set it with a length of 1...
Can the that be fixed?

Here's what I'm trying to do now:
It should create Str1 as a string and set it to hex 40 (the @ sign)

Here's my code again...:


Code:
.NOLIST
#define   EQU   .equ
#define   equ   .equ
#define   END   .end
#define   end   .end
#define   ProgStart   $9D95
#include "ti83plus.inc"
.LIST

    .org   ProgStart - 2
    .db    t2ByteTok, tAsmCmp

    ld     HL,Str1name
    B_CALL(_Mov9ToOP1)
    ld     HL,1
    B_CALL(_CreateStrng)
    ld     A,40h
    ld     BC,1
    B_CALL(_MemSet)
    ret

Str1name:
   .db     StrngObj,tVarStrng,tStr1,0,0

.end
end


Thanks to anyone who's tried, and to those who will try to help =)
Uh... why the bcall? Look at my code above where I set DE directly....


Code:
inc de
inc de ;get past size bytes
ld a, 0x40
ld (de), a


thats all you needed to do....
Alright. I don't know how exactly that works, but putting it in and trying it, it doesn't work.

Here's my code, now...

Code:
.NOLIST
#define   EQU   .equ
#define   equ   .equ
#define   END   .end
#define   end   .end
#define   ProgStart   $9D95
#include "ti83plus.inc"
.LIST

    .org   ProgStart - 2
    .db    t2ByteTok, tAsmCmp

    ld     HL,Str1name
    B_CALL(_Mov9ToOP1)
    ld     HL,1
    B_CALL(_CreateStrng)
    ; ld     A,40h
    ; ld     BC,1
    ; B_CALL(_MemSet)
    inc    DE
    inc    DE
    ld     A, 0x40
    ld     (DE), A
    ret

Str1name:
   .db     StrngObj,tVarStrng,tStr1,0,0

.end
end


Edit: I forgot to say how it didn't work...
Displaying Str1 after running the program reveals it's still set as "?"
I finally got it. I don't know why Kllrnohj says "0x40", but $40 works. Here's my ending code.

Code:
.NOLIST
#define   EQU   .equ
#define   equ   .equ
#define   END   .end
#define   end   .end
#define   ProgStart   $9D95
#include "ti83plus.inc"
.LIST

    .org   ProgStart - 2
    .db    t2ByteTok, tAsmCmp

    ld     HL,Str1name
    B_CALL(_Mov9ToOP1)
    ld     HL,1
    B_CALL(_CreateStrng)
    inc    DE
    inc    DE
    ld     A, $40
    ld     (DE), A
    ret

Str1name:
   .db     StrngObj,tVarStrng,tStr1,0,0,0,0,0

.end
end


So this program creates Str1 with a length of 1 and sets it's only byte to hex 40. Which turns out to be " and ", not "@", but I'll figure it out.

Thanks to Kllrnohj who gave that last piece of code that worked with a little change, and the idea of padding the data for Str1name. =D

Thanks to everyone who tried to help. =)
0x40 and $40 (and 40h, for that matter) should all be interpreted to be hex 40. 0x is just an alternate prefix to specify hex (like $).
I know that, Tari, but it didn't work here for me. I'd rather use either of the other two while programming for TI-83+ assembly, anyway.
Ah, ok. It's probably that whatever assembler you're using doesn't like the 0x prefix, but you probably figured that out.
KevinJr42 wrote:
I finally got it. I don't know why Kllrnohj says "0x40", but $40 works.


Because Kllrnohj mostly does computer programming where you can only use 0x to designate a hex value Smile (sorry about that)
I have no idea why the "rst" thing didn't work for you - I always use it instead of the bcall, since it's faster and 2 bytes smaller.
Well at least I got it. Thanks everyone =)
KevinJr42 wrote:
Well at least I got it. Thanks everyone =)
No problemo. So where are you planning on going with this particular project?
Well I wanted to be able to type certain characters on my calculator to use in my BASIC programs.
I don't have a link for the calculator/computer, so that would be hard.
After making this program, I opened it in a hex editor and copied it to my calculator, and I just change the part where the data for Str1 goes.

This is my source right now (I changed it to 2 characters):

Code:
.NOLIST
#define   EQU   .equ
#define   equ   .equ
#define   END   .end
#define   end   .end
#define   ProgStart   $9D95
#include "ti83plus.inc"
.LIST

    .org   ProgStart - 2
    .db    t2ByteTok, tAsmCmp

    ld     HL,Str1name
    B_CALL(_Mov9ToOP1)
    ld     HL,2
    B_CALL(_CreateStrng)
    inc    DE
    inc    DE
    ld     A, $BB
    ld     (DE), A
    inc    DE
    ld     A, $AC
    ld     (DE), A
    ret

Str1name:
   .db     StrngObj,tVarStrng,tStr1,0,0,0,0,0

.end
end

This is prgmSSTR:

Code:
DelVar Str1
:Asm(prgmSSTRθ
:ClrHome
:Disp "Str1:"
:Output(1,6,Str1

This is prgmSSTRθ (The parts BB and AC at the end of lines 3 and 4 of hex I change to get different characters, it's set to give me the character Ω right now):

Code:
:AsmPrgm
:21AB9DEF7A41
:210200EF2743
:13133EBB
:12133EAC
:12C904AA
:000000000000

So if I were to run prgmSSTR, it would delete Str1 (so it doesn't make a duplicate since the assembly program doesn't check), It would run the assembly program which makes Str1 to length 2 and sets the data to "Ω", Clears the home screen and shows me what Str1 has been set to.

To "paste" it in a program, I just use Rcl Str1 and delete the quotes if I need to.

I would like the assembly program to use real variables (A, B) or something, and in the basic program, I could just put "Prompt A:Prompt B", but I can still do without that...

I'm not publishing it (i.e. at ticalc.org) though, it's for my own use.
I was about to suggest Dan (tifreak8x)'s and my Symbols 2.1 (http://www.ticalc.org/archives/files/fileinfo/384/38404.html), but I suppose you can't use it. You really should try investing in one of the cables; it's incredibly useful.
  
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 2
» 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