Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: nxtboy III on February 18, 2012, 01:57:59 am

Title: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 01:57:59 am
Hi,
I was wondering if somebody could make me a .8xp in ASM that counts to 10,000 and displays the number it is on on the screen. This is so I can test the speed of my calc and compare it to other stuff.

Thanks, and have a nice day,
nxtboy III
Title: Re: Count to 10,000 in ASM
Post by: Deep Toaster on February 18, 2012, 10:39:29 am
Well, you could use this, but how are you planning to test speed with it?
Quote from: Z80 Assembly
#include    "ti83plus.inc"
#define     progStart   $9D95
.org        progStart-2
.db         $BB,$6D
   bcall(_ClrLCDFull)
   bcall(_HomeUp)
    ld  HL, 0
Loop:
    push    HL
    bcall(_DispHL)
    bcall(_NewLine)
    pop     HL
    inc HL
    ld  DE, 10000
    xor A
    sbc HL, DE
    add HL, DE
    jr  nz, Loop
    ret
Generated by the BBify'r (http://clrhome.org/resources/bbify/ (http://clrhome.org/resources/bbify/))
But it's not very useful at all, since most of the time it takes is to display the number, so it's not much faster than doing it in TI-BASIC (left side is ASM, right side is BASIC):
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 10:43:11 am
Is there a way to make it not display a new line each time? Just on the same line?
Title: Re: Count to 10,000 in ASM
Post by: Deep Toaster on February 18, 2012, 10:48:22 am
It would just keep going to the right, and after three numbers you wouldn't be able to see any more.
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 10:49:30 am
Oh. Well I was doing this so I could test the speed between my NXT and my calc.
Title: Re: Count to 10,000 in ASM
Post by: Yeong on February 18, 2012, 10:50:56 am
maybe add extra clrLCDFull somewhere in the loop? even though it will slow things down? or set pencol or whatever it's called?
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 10:53:38 am
I made a program for it on my NXT in assembly that counts and displays the number.(It displays the number in the same place the whole time.) It counts to 10,000 in about 4 seconds.

EDIT: i'm sorry. i accidentally hit the modify button instead of quote =/
*shmibs
Title: Re: Count to 10,000 in ASM
Post by: Runer112 on February 18, 2012, 11:07:00 am
Without displaying numbers, an optimized z80 assembly loop structure could count to 10000 in about 1/30th of a second. Although I would not recommend comparing processor/language speed by seeing how fast they can count to 10000, simply because there are multiple variables that will skew the results an extreme amount; display or not, scroll or not, how fast the system text routine is, how the screen is updated, and so on. If you have a project in mind, I would say the best way to compare speed is simply to start coding the project for both platforms and compare simplified, test versions of them.
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 11:08:58 am
??? Are you sure it can count to 10,000 in about 1/30th of a second?
That seems super fast.......
Well, here it is for my NXT:(Sorry it's an avi)

For the calc one:
Could you edit the TI 84 program so it stops when it gets to 10,000?
Title: Re: Count to 10,000 in ASM
Post by: Yeong on February 18, 2012, 11:15:57 am
you could add this at the end of the loop: If Ans=10000:Stop
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 11:16:43 am
Do you think you could add it and compile it to an 8xp for me? I don't know how.
Title: Re: Count to 10,000 in ASM
Post by: Yeong on February 18, 2012, 11:17:58 am
I don't have the source file XP
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 11:19:55 am
Well there's this if this helps:

#include    "ti83plus.inc"
#define     progStart   $9D95
.org        progStart-2
.db         $BB,$6D
   bcall(_ClrLCDFull)
   bcall(_HomeUp)
    ld  HL, 0
Loop:
    push    HL
    bcall(_DispHL)
    bcall(_NewLine)
    pop     HL
    inc HL
    ld  DE, 10000
    xor A
    sbc HL, DE
    add HL, DE
    jr  nz, Loop
    ret
Title: Re: Count to 10,000 in ASM
Post by: Yeong on February 18, 2012, 11:23:15 am
oh. I thought you were asking about TI-BASIC file XD
sorry, I don't have a compiler.
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 11:24:00 am
What about in BASIC?
Is there another easy way I can compare speed?


EDIT: My NXT counts to 1 million in about 39 seconds in assembly.
Title: Re: Count to 10,000 in ASM
Post by: Keoni29 on February 18, 2012, 11:31:15 am
You might wanna skip frames :)
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 11:32:56 am
Too bad I do not have a compiler. I just want the program for the calc to stop when it gets to 10,000 , without displaying the number.
Title: Re: Count to 10,000 in ASM
Post by: MGOS on February 18, 2012, 11:42:08 am
Why don't you use axe? You'll get a less optimized, but decent asm program.
Code: [Select]
0->C
While C+1->C-10000
End
Disp "Finished"
My TI 83+ does that in less than a second.
Title: Re: Count to 10,000 in ASM
Post by: Yeong on February 18, 2012, 11:43:38 am
and if you use TI-84+ speed, it's 2.5 times faster than TI 83+ does, so... you do the math XD
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 11:54:45 am
How many seconds does it take for it to get to 100,000 in Axe? I can't calculate it because all you said was "less than a second."

BTW, what does the -> mean in Axe?

EDIT: Could you send me the .8xp?
Title: Re: Count to 10,000 in ASM
Post by: Yeong on February 18, 2012, 11:57:00 am
it's actually →, which is used for storing.
also, axe only goes up to 65535. D:
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 12:00:47 pm
Ok, then make it count to 60,000.

EDIT: So I guess Axe can only handle 16-bit values. The max for a 16-bit value on my NXT is also 65535, if it is unsigned (Can only be a postitive number). But the NXT can handle 32-bit values. The max for an unsigned 32-bit value is 4294967295.
Title: Re: Count to 10,000 in ASM
Post by: MGOS on February 18, 2012, 12:05:01 pm
My TI 83+ takes 1.39 seconds from 0 to 60000 (interrupts turned off).
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 12:06:24 pm
My NXT takes about 1.5 seconds to count from 60000 to 0.

EDIT: Actually, it takes about 2.2 seconds.
Title: Re: Count to 10,000 in ASM
Post by: DJ Omnimaga on February 18, 2012, 02:40:05 pm
The reason why nxtboy III asked this program is because he wanted to compare the speed of the LEGO Mindstorm NXT with the TI-84 Plus. Assuming his Mindstorm program did not display a counter or update the LCD until the very end, then it seems like the 84+ is much faster despite being 15 MHz instead of over 40.
Title: Re: Count to 10,000 in ASM
Post by: AngelFish on February 18, 2012, 03:14:05 pm
My NXT takes about 1.5 seconds to count from 60000 to 0.

EDIT: Actually, it takes about 2.2 seconds.

Did you make sure to turn off whatever OS overhead the lego thing has and write the test in a compiled language? The z80 is a very old chip, so I'd be a bit surprised if the more modern chip in an NXT is beaten by it.

EDIT:

??? Are you sure it can count to 10,000 in about 1/30th of a second?
That seems super fast.......


The z80 in an 84+ is running at around 15MHz in full speed. That's 15 million cycles per second, which gives a couple million operations per second. counting to 10,000 in a fraction of a second seems a lot more reasonable in that light. Also, counting isn't the best way to compare CPUs. More modern CPUs are going to be able to take advantage of counter hardware or very, very fast ALUs.
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 05:42:42 pm
I don't think there is a way to turn off the OS overhead, unless it already does.
Well the NXT's processor runs at 48 Mhz, though it seems slower.

What's an ALU?

EDIT: Looked it up. The ALU is the part that calculates math stuff.
Title: Re: Count to 10,000 in ASM
Post by: AngelFish on February 18, 2012, 06:08:25 pm
Looks like the NXT has an ARM7 chip inside. I can pretty much guarantee that an ARM7 at 48 MHz is faster than the z80 in the 84+. It's RISC, it has a real pipeline, caching, etc. If it's indeed an ARM7, then there's no real need to do anything more than compile this in with whatever your favorite NXT C/C++ compiler is and compare it to the Axe code given previously.

Code: [Select]
#include <stdio.h>
int main(){
  a=60000;
  while(a){
    a=a-1;
  }
  printf("Done\n");
  return 0;
}

Edit: Forgot main()...
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 18, 2012, 06:15:05 pm
Well... That's not exactly how to program it but I made a program that basically does that, and it goes slower than the calc. It would be better if I had a .8xp that does that for the calc so I can test it. Could someone post a .8xp for that?
Title: Re: Count to 10,000 in ASM
Post by: DJ Omnimaga on February 19, 2012, 02:29:46 am
Well the above code is written in C so someone would need to turn it in Z80.
Title: Re: Count to 10,000 in ASM
Post by: thepenguin77 on February 19, 2012, 07:36:58 pm
It depends what your goals are, but the fastest way to count from 0 to 60,000 (definition: 1 register holds every single value from 0 to 60,000) would look like this:

Code: [Select]
ld hl, 0
ld de, 0
ld bc, 60000
ldir

This code would take .076 seconds to run at your standard 16.5 Mhz. HL and DE would both count to 60,000 and BC would count from 60,000 to 0. Going to 10,000 would take .013.


Edit:
  Technically there is a faster way, but it requires 120,000 bytes of instructions.
Title: Re: Count to 10,000 in ASM
Post by: shmibs on February 20, 2012, 01:51:14 am
I made a program for it on my NXT in assembly that counts and displays the number.(It displays the number in the same place the whole time.) It counts to 10,000 in about 4 seconds.
there's no way that you are getting 2,500 frames per second. i'm guessing that whatever method your using isn't "turning off the OS overhead" like qwerty said, and that it manages screen updates itself with interrupts, and that all you're doing is writing the character data to a RAM buffer somewhere.
the processor in the NXT brick runs at 48 MHz (or so the internet tells me), and the z80 in the 83+ and 84+ run at 6 MHz and 15 MHz respectively, so it will, indeed, count faster. like qwerty said, that's not the best way to determine "how fast it will run," but when the differences are that obvious, it's not a question.
Title: Re: Count to 10,000 in ASM
Post by: DJ Omnimaga on February 20, 2012, 01:56:26 am
(off-topic: everytime someone posts in this topic, due to the topic title in OmnomIRC I always think somebody revived this (http://z9.invisionfree.com/omnimaga/index.php?showtopic=93) thread but outside the spam sub-forum X.x)
Title: Re: Count to 10,000 in ASM
Post by: calc84maniac on February 20, 2012, 02:39:40 am
Also, the NXT has an ARM7 processor, correct? The architecture itself is faster than the z80 too (stuff takes less clock cycles, there are more registers, 32-bit instead of 8-bit, etc)
Title: Re: Count to 10,000 in ASM
Post by: DJ Omnimaga on February 20, 2012, 03:06:54 am
Maybe the screen/LCD driver of the NXT is just considerably slower than the already slow 83+/84+ one, or worse, the Prizm one?
Title: Re: Count to 10,000 in ASM
Post by: nxtboy III on February 20, 2012, 09:26:22 am
Yes, it has a 32-bit ARM7 Microprocessor running at 48 Mhz.
DJ_O-
Well actually, even if I make the program not display anything, it is faster than the TI 84 not displaying anything. And I actually think the NXT's display driver is faster than the Ti-84's. I can tell you the refresh rate. It refreshes every 17 milliseconds.