[ASM] How to ld hl,sp?

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

[ASM] How to ld hl,sp?

Post 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...
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
User avatar
qarnos
Maxcoderz Staff
Posts: 227
Joined: Thu 01 Dec, 2005 9:04 am
Location: Melbourne, Australia

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

Post 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)
"I don't know why a refrigerator is now involved, but put that aside for now". - Jim e on unitedti.org

avatar courtesy of driesguldolf.
User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

Post 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
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post 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).
Last edited by benryves on Thu 06 Dec, 2007 11:23 am, edited 1 time in total.
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post 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:
User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

Post by Timendus »

I guess we should be grateful for that ;)
Anyway, it's working. See mailinglist for details.
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
Liazon
Calc Guru
Posts: 962
Joined: Thu 27 Oct, 2005 8:28 pm

Post by Liazon »

or ASMin28's list of instructions is useful.
Image Image Image
User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

Post 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... :)
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
qarnos
Maxcoderz Staff
Posts: 227
Joined: Thu 01 Dec, 2005 9:04 am
Location: Melbourne, Australia

Post by qarnos »

And don't forget Thomas Scherrers Z80 support page. Tons of info there.
"I don't know why a refrigerator is now involved, but put that aside for now". - Jim e on unitedti.org

avatar courtesy of driesguldolf.
User avatar
qarnos
Maxcoderz Staff
Posts: 227
Joined: Thu 01 Dec, 2005 9:04 am
Location: Melbourne, Australia

Post 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.
"I don't know why a refrigerator is now involved, but put that aside for now". - Jim e on unitedti.org

avatar courtesy of driesguldolf.
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

That one on ticalc is really bad. Tabulation cropped off the last digit on a lot of opcodes.
Image
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post 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
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
calc84maniac
Regular Member
Posts: 112
Joined: Wed 18 Oct, 2006 7:34 pm
Location: The ex-planet Pluto
Contact:

Post 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
~calc84maniac has spoken.

Projects:
F-Zero 83+
Project M (Super Mario for 83+)
Post Reply