Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Jerros on July 02, 2011, 08:45:47 am

Title: List of Bytes/Time each command takes?
Post by: Jerros on July 02, 2011, 08:45:47 am
Is there any list stating all .z80 ASM commands with the number of T-cycles and Bytes they take? Or actually just the latter, since there are sites giving the number of T-cycles already, but no luck on finding the bytes per command yet... This would really help making speed/lenth decisions.
Thank you!
Title: Re: List of Bytes/Time each command takes?
Post by: JosJuice on July 02, 2011, 09:02:50 am
I remember seeing a .txt file with that information somewhere, but I can't remember where it was... It might've been on WikiTI, or brandonw.net.
Title: Re: List of Bytes/Time each command takes?
Post by: thepenguin77 on July 02, 2011, 09:22:35 am
Oh, boy jerros, these are so many.

1. There is zilog's official documentation (http://www.zilog.com/docs/z80/um0080.pdf). It's drawn out over the course of a pdf, but it's really in depth.
2. Learn asm in 28 days has a set of pages (http://eeezor.ec3club.tk/Files/Resources/Tutorials/ASMin28Days/ref/z80is.html) containing almost all of the instructions. (It is missing a few like jp (hl))
3. There's this cool table (http://davidgom.co.cc/z80table.html). (Although it doesn't have t-states and the bytes take some figuring.
4. WikiTi has a page (http://wikiti.brandonw.net/index.php?title=Z80_Instruction_Set) on the matter.

So there are four. Of those four, I personally use 2, and if I want to be absolutely sure of something, I use 1. Option 4 is probably the best "table," but it could use some color.

Edit:
    I never realized how in depth zilog's manual is. They give an example of each instruction.
Title: Re: List of Bytes/Time each command takes?
Post by: ZippyDee on July 02, 2011, 09:40:49 am
You can use this page (http://www.z80.info/z80sean.txt), too. On the left you can see the bytes, and cycles are there under the heading "T". However it doesn't seem to have the number of cycles for most of the undocumented commands.
Title: Re: List of Bytes/Time each command takes?
Post by: Deep Toaster on July 02, 2011, 05:33:04 pm
http://clrhome.org/table/ (hover for size, time, and flags)[/ad]

I use 28 Days's instruction set (http://eeezor.ec3club.tk/Files/Resources/Tutorials/ASMin28Days/ref/z80is.html) all the time for more detailed stuff.
Title: Re: List of Bytes/Time each command takes?
Post by: Jerros on July 03, 2011, 04:01:47 am
http://clrhome.co.cc/resources/table/ (hover for size, time, and flags)[/ad]
This is what I was looking for, thanks! I've found all those other tables before too, though didn't knew how to figure the 'size' of the commands out of all those numbers... But that link you provded, Deep Thought, directly states so, so thank you! This'll certainly help somewhat.

EDIT:
Oh, just one more... the size/time of a Label? :)
Title: Re: List of Bytes/Time each command takes?
Post by: calcdude84se on July 03, 2011, 05:54:16 am
A label is just a nice reference point for other instructions to refer to. It's just a number, and it's not any code at all.
Title: Re: List of Bytes/Time each command takes?
Post by: Jerros on July 03, 2011, 08:22:42 am
A label is just a nice reference point for other instructions to refer to. It's just a number, and it's not any code at all.
But they have to take up space... right? Ahh well, s'pose I have all the info now, thanks.
Title: Re: List of Bytes/Time each command takes?
Post by: Deep Toaster on July 03, 2011, 03:18:57 pm
A label is just a nice reference point for other instructions to refer to. It's just a number, and it's not any code at all.
But they have to take up space... right? Ahh well, s'pose I have all the info now, thanks.

Nope, it's more like a bookmark for the assembler to keep track of. It doesn't affect the size of the compiled program at all -- try it!

How it works is this: As you know, each byte of memory on the calculator has an address (between $0000 and $FFFF, where everything $8000 and above is usually RAM). This includes every byte of the program, which gets moved to $9D95 whenever it gets executed. (In other words, while a program is running, the first byte is at address $9D95, the second byte at $9D96, and so on.)

So when you create a label, all it's doing is giving a name to the address of the instruction immediately following it. Something like

Code: (Z80 assembly) [Select]
.org $9D95 - 2
.db $BB,$6D
    LD HL,0    ; This instruction starts at $9D95 and is three bytes long
Label:
    LD DE,Label    ; This instruction starts at $9D98 and is three bytes long

is entirely equivalent to

Code: (Z80 assembly) [Select]
.org $9D95 - 2
.db $BB,$6D
    LD HL,0    ; This instruction starts at $9D95 and is three bytes long
Label .EQU $9D98
    LD DE,Label    ; This instruction starts at $9D98 and is three bytes long

and both are exactly the same as

Code: (Z80 assembly) [Select]
.org $9D95 - 2
.db $BB,$6D
    LD HL,0    ; This instruction starts at $9D95 and is three bytes long
    LD DE,$    ; This instruction starts at $9D98 and is three bytes long

and even

Code: (Z80 assembly) [Select]
.org $9D95 - 2
.db $BB,$6D
    LD HL,0    ; This instruction starts at $9D95 and is three bytes long
    LD DE,$9D98    ; This instruction starts at $9D98 and is three bytes long

Hope that clears things up :)