Page 1 of 1

[ASM] How to ld hl,sp?

Posted: Thu 06 Dec, 2007 9:09 am
by Timendus
I want to get the stack pointer. How do I do that? There's a ld sp,hl opcode according to WikiTi, but not the other way around...

Re: [ASM] How to ld hl,sp?

Posted: Thu 06 Dec, 2007 9:36 am
by qarnos
Timendus wrote:I want to get the stack pointer. How do I do that? There's a ld sp,hl opcode according to WikiTi, but not the other way around...

Code: Select all

ld hl, 0
add hl, sp
:)

If you just want to store SP somewhere, there is also:

Code: Select all

ld (somewhere), sp

...muck with sp...

ld sp, (somewhere)

Posted: Thu 06 Dec, 2007 10:09 am
by Timendus
Really? Why aren't those opcodes in the WikiTi? :mrgreen:

Thanks!

Edit: Never mind, really stupid question :)
Q 16-bit register: bc, de, hl/ix/iy, sp

Posted: Thu 06 Dec, 2007 11:06 am
by benryves
Timendus wrote:Really? Why aren't those opcodes in the WikiTi? :mrgreen:
There's always the Z80 User Manual if you want another reference. :)

(Edit: Hm, didn't realise WikiTI had anything about the Z80 on it at all).

Posted: Thu 06 Dec, 2007 11:16 am
by CoBB
Timendus wrote:Edit: Never mind, really stupid question :)
Q 16-bit register: bc, de, hl/ix/iy, sp
Sorry about the obscure indirections in the reference, it’s to make sure that only people who understand pointers will make use of it. :mrgreen:

Posted: Thu 06 Dec, 2007 11:17 am
by Timendus
I guess we should be grateful for that ;)
Anyway, it's working. See mailinglist for details.

Posted: Thu 06 Dec, 2007 10:59 pm
by Liazon
or ASMin28's list of instructions is useful.

Posted: Thu 06 Dec, 2007 11:41 pm
by Timendus
I usually just Google for a random z80 opcode reference when I need one, but this time I happened to be on WikiTi... :)

Posted: Fri 07 Dec, 2007 3:29 am
by tr1p1ea

Posted: Fri 07 Dec, 2007 5:54 am
by qarnos
And don't forget Thomas Scherrers Z80 support page. Tons of info there.

Posted: Fri 07 Dec, 2007 7:33 am
by qarnos
tr1p1ea wrote:I keep this one close by: http://www.ticalc.org/archives/files/fi ... 12883.html

:).
Why is it that this doc and asmguru both list the conditional JP instructions as taking 1 T-State when the jump is not taken?

My guess is that one of them left off the "0" and the other copied the mistake.

Posted: Fri 07 Dec, 2007 11:20 am
by Jim e
That one on ticalc is really bad. Tabulation cropped off the last digit on a lot of opcodes.

Posted: Sat 08 Dec, 2007 12:48 pm
by tr1p1ea
I have noticed a few mistakes, but i wouldnt say its a terrible reference. Certainly helped me out :).

Another one i find handy is: http://www.geocities.com/SiliconValley/ ... 0_home.htm

Posted: Wed 26 Dec, 2007 7:28 am
by calc84maniac
Heh, might as well post mine too. It's concise and to the point, holds most z80 command info you'll ever need (and more), and easily printable on one page.
calc84maniac's z80 reference