This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 11 Sep 2003 03:16:02 pm    Post subject:

Ok that will be a very simple task to complete. I should have it done by tonight. Very Happy

Converting a variable to a string providing that it is a 16-bit number is realatively easy to achieve in asm. Stay tuned for the source. Do you want it in hex or the actual program? If you want the actual binary program, please post your email address.
Back to top
Ben Trettel


Member


Joined: 17 Jul 2003
Posts: 153

Posted: 11 Sep 2003 06:28:38 pm    Post subject:

Umm... I don't know much about assembly, but I think that I would want it in hex so I can type it in my calc and do AsmComp(, right? The actual program I guess would be good, too, but I don't have a link cable that works most of the time.
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 11 Sep 2003 08:50:08 pm    Post subject:

Ok here you go, the moment you were waiting for.

This program will take any number between 0 and 65535 in the variable X and convert it to a string which in turn is stored into Str0

Code:
AsmPrgm
EFC541
EFE04A
EFEF4A
626B11
D29D06
05EF0F
40C630
121B10
F7EFC5
4121D4
9DE7EF
F14238
03EF51
432105
00EF27
431313
21CE9D
010500
EDB0C9
000000
000000
04AA09
00

The hex code for your convienience. Type it into a new program then name it whatever you want when you use the AsmComp( command.

For optimization purposes I made it so that it will produce an error if X does not exist or if Str0 is archived.

It is a really tiny program. Only 86 bytes on calc. It will convert the variable to a 5 character string.

If the variable X had 500 stored in it. The String created (Str0) would hold this "00500"

500->X
Asm(prgmVARTOSTR
Disp Str0

If you wanted to display the string without the zero's in front you would simply
Disp expr(Str0

It would display 500 instead of 00500.

Now for all you learning asm or don't know how to do this type of thing in asm. Here's a little source code for you.


Code:
.nolist
#include "ti83plus.inc"
.org usermem-2
.db $BB,$6D
.list

 bcall(_zeroop1)
 bcall(_rclx)
 bcall(_convop1)
 ld h,d
 ld l,e
 ld de,datastring+4
 ld b,5
writestring:
 bcall(_DivHLBy10)
 add a,$30
 ld (de),a
 dec de
 djnz writestring
 bcall(_zeroop1)
 ld hl,stringname
 rst 20h
 bcall(_chkfindsym)
 bcallnc(_delvar)
 ld hl,5
 bcall(_CreateStrng)
 inc de
 inc de
 ld hl,datastring
 ld bc,$0005
 ldir
 ret
datastring:
 .db 0,0,0,0,0,0
stringname:
 .db Strngobj,tvarStrng,tStr0,0
.end


That was fun to do. It's the first asm programming I've done in 2 months.

Enjoy Ben!


Last edited by Guest on 11 Sep 2003 08:56:00 pm; edited 1 time in total
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 11 Sep 2003 09:14:53 pm    Post subject:

I don't know but, I'm pretty sure I can make a better version of that. 89 bytes you say? Okay, I'll try to beat that!
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 11 Sep 2003 09:40:16 pm    Post subject:

That's with a 8 byte title. Minus 7 bytes for a 1 byte title and you have 82 bytes.

I can make many optimizations to it.


Last edited by Guest on 12 Sep 2003 12:01:44 am; edited 1 time in total
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 11 Sep 2003 10:46:04 pm    Post subject:

Ok I forgot that this method only allows a number up to 9999. Which is ok because the technique to do a bigger number, is slightly larger. Maybe 15 bytes larger but oh well. It is not necessary for a larger number in this case as forementioned.

As for optimization purposes.

Here's my optimization of my own source.


Code:
nolist
#include "ti83plus.inc"
.org usermem-2
.db $BB,$6D
.list

   bcall(_rclx)
   bcall(_convop1)
   push de
   ld hl,stringname
   rst 20h
   bcall(_chkFindSym)
   bcallnc(_delvar)
   ld hl,4
   bcall(_CreateStrng)
   inc de
   inc de
   inc de
   inc de
   inc de
   pop hl
   ld b,4
writestring:
   bcall(_DivHLBy10)
   add a,$30
   ld (de),a
   dec de
   djnz writestring
   ret
stringname:
   .db Strngobj,tvarStrng,tStr0,0
.end


Hex code


Code:
AsmPrgm
EFE04A
EFEF4A
D521C0
9DE7EF
F14238
03EF51
432104
00EF27
431313
131313
E10604
EF0F40
C63012
1B10F7
C904AA
0900


Fully optimized with a 1 byte title it takes a mere 58 bytes now.


Last edited by Guest on 11 Sep 2003 10:49:25 pm; edited 1 time in total
Back to top
Ben Trettel


Member


Joined: 17 Jul 2003
Posts: 153

Posted: 12 Sep 2003 04:39:18 am    Post subject:

Thanks! I'm giving you credit, too! Cool
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 12 Sep 2003 08:31:02 am    Post subject:

Thank you Ben. :|

I hope that the program will suit your needs.
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 12 Sep 2003 03:10:13 pm    Post subject:

a. Mine takes 60 bytes. But then I haven't made a second version like yours. (p.s. it allows for any real number you can fit into X).
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 12 Sep 2003 06:39:01 pm    Post subject:

What's the point? A number that large wasn't required. It isn't very hard to do, although I am interested to see how you accomplished it.
Back to top
JacobdeHaan


Member


Joined: 10 Jul 2003
Posts: 165

Posted: 15 Sep 2003 12:55:03 am    Post subject:

I feel sooooooooooooo stupid.

Last edited by Guest on 15 Sep 2003 12:55:13 am; edited 1 time in total
Back to top
Display posts from previous:   
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
    » Goto page Previous  1, 2
» View previous topic :: View next topic  
Page 2 of 2 » All times are UTC - 5 Hours

 

Advertisement