[TI ASM] Asm Help

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

L-Man
New Member
Posts: 55
Joined: Fri 17 Dec, 2004 5:34 pm
Location: Utah
Contact:

[TI ASM] Asm Help

Post by L-Man »

well ionlargesprite uses the adress of ix to find the sprite right? well why cant you load the adress somewhere else like this:

Code: Select all

ld hl,TempSprite
ld (hl),MarioSprite
is there some way to do this?
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

yes, you can store the adress in hl... if you want to to retrieve to get the adress from hl to ix, you can do that by simply:

Code: Select all

push hl
pop ix
I am not sure if that's what you asking though
Image
L-Man
New Member
Posts: 55
Joined: Fri 17 Dec, 2004 5:34 pm
Location: Utah
Contact:

umm

Post by L-Man »

no not really!
k i want to load the adress of a sprite MarioRight in to a temporary variable called TempSprite so i can call ionlargesprite with
ld ix,TempSprite
and having tempsprite have the adress of MarioRight so when i call ionlargesprite it loads MarioRight Sprite.

Thats my question
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

than you need two variables, because a adress is a 16bit register.

storing the adress (located in hl) would go like

Code: Select all

ld a,h
ld (tempSpriteAdress),a
ld a,l
ld (tempSpriteAdress+1),a
and I think you can guess how loading goes... :)

to use it with the ion routine, you have to load it of course... it's not just simply ix,tempspriteadress... there is a difference between loading data and loading a pointer :)
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 »

If you want to store it in HL you would have to do something akin to:

Code: Select all

ld a,(hl)
inc hl
ld h,(hl)
ld l,a
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

I don't think what you are trying to do is possible tr1p...

Code: Select all

ld a,(hl) 
inc hl 
ld h,(hl) 
ld l,a
would be rather:

Code: Select all

ld a,(hl) 
ld b,a
inc hl
ld a,(hl)
ld h,a
ld l,b
Image
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

You're wrong, Vincent, and tr1p is right. Also, referring to your previous post, LD (ArbitraryAddress), HL is also possible. Check out my LD table if you don't believe me. ;) BTW you have some endianness problem there, the high byte comes after the low byte in the Z80.
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

CoBB wrote:You're wrong, Vincent, and tr1p is right. Check out my LD table if you don't believe me. ;)
Hmmm... I already was afraid, that my thoughts would be wrong ;) ... Don't worry, how couldn't I believe one of the z80 gods :P
CoBB wrote:Also, referring to your previous post, LD (ArbitraryAddress), HL is also possible.
so if you do LD (ArbitraryAddress),HL where will it go? It doesn't fit in a 8bit register I suppose, so it most likely will use both (ArbitraryAddress) and (ArbitraryAddress+1),right? and does that mean that LD HL,(Arbitrary Adress) does also work?
CoBB wrote:BTW you have some endianness problem there, the high byte comes after the low byte in the Z80.
endianness problem? I don't get it... :oops:
Image
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

As stated in my previous post: the low byte goes to Address, the high byte to Address+1. And yes, it's possible the other way around, too.

Endianness is exactly the specification of byte order. Z80 and Intel CPUs are little endian, i. e. numbers are stored with their lowest byte first. As opposed to this, Motorola CPUs are bigendian, storing everything in the exact opposite order.
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 »

Yes so if you were to store say $FEBC at your ArbitraryAddress (on a z80), in memory it would look like:

(ArbitraryAddress) = $BC
(ArbitraryAddress+1) = $FE
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
L-Man
New Member
Posts: 55
Joined: Fri 17 Dec, 2004 5:34 pm
Location: Utah
Contact:

Is this right?

Post by L-Man »

so if im understanding correctly from you guys i can do this:

Code: Select all

ld hl,MarioSprite
ld (TempSprite),hl
....
....
...
ld ix,TempSprite
call ionlargeSprite
call ionfastcopy
right or am i not using inderection? or something else
thanks
CalcKing
Regular Member
Posts: 147
Joined: Sat 18 Dec, 2004 3:24 am
Contact:

Post by CalcKing »

Since you stored hl (the pointer) to the memory location TempSprite, you will have to use indirection to get the pointer data into ix.

Code: Select all

ld hl,MarioSprite
ld (TempSprite),hl
....
....
...
ld ix,(TempSprite)
call ionlargeSprite
call ionfastcopy
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

Actually, it's not that hard to see how it works. All you have to understand is that every symbol (labels you defined) is turned into a number. If TempSprite is $9000 and MarioSprite $9876 for instance, the resulting code will be:

Code: Select all

ld hl,$9876
ld ($9000),hl
Now obviously, if you want to retrieve the value stored at $9000, you shouldn't write

Code: Select all

ld ix,$9000
since that sets ix to $9000 by definition.

Code: Select all

ld ix,($9000)
does the job, ix will be $9876 unless you overwrote the byte at $9000 or $9001 in the meantime.
L-Man
New Member
Posts: 55
Joined: Fri 17 Dec, 2004 5:34 pm
Location: Utah
Contact:

THANKS!

Post by L-Man »

You guys are awesome!!!!!! I get it now! :D :D :D
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 »

You know that you can also do:

Code: Select all

ld hl,TempSprite
push hl
pop ix
This is only if you want to get whats in hl to ix ... which i dont know if this is what you want or not?
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
Post Reply