swivelgames wrote:
Oh I see. And then "ld h,(hl)" would store the result of hl(results only because its in parenthesis) into h, right? or vise versa? What exactly does ld do?

Its kind of confusing, because at one point I thought I saw ld being used to store/change variables, but then I saw that it was used to call them, and then used as a conditional statement (ld a,label = If A then Label; Not exact).


ld is like var = value. Thats all it does Smile (although what the var and value is can vary, of course). The parenthesis around hl mean to use the value at the memory address contained in hl (C equivalent: var = *char_ptr; )
swivelgames wrote:
Thanks for all the sources and what not. Its helping a lot.

I asked this question on UTI, but I'm going to ask the question on here as well...

Liazon sent me the source for the TurkeyHunt game. I'm looking to work on it a bit, maybe build off of it just so I get the feel for programming (its easier to add to something already created ^^,). My question was, how would I check if the user has two keys pressed? If they do, I think I know how to make the character to go diagonal, but I'm not sure how to check for two keys at one time. Help?

----------------
Now playing: 30 Seconds to Mars - The Fantasy
via FoxyTunes


o.o wow I forgot my 1st program was that n00b

i should probably use it as an example program/assignment/self quiz if and when I write an ASM tutorial.
Regarding ld: No, it's not like a conditional if at all; that's what you use opcodes like cp for.
Oh the confusion! Thats what I said I thought it was the first time...

So this:
cp hl
ld a,(hl)
(not pasted from anywhere)
would set a to hl? or...?

At the moment, I have no tutorials handy, for my computer does not have internet. My mom just swapped over to DSL and is using 2Wire and I can't seem to connect to it with my Netgear MA111. But regardless of that, the code I put up: that would set 'a' to the value of 'hl' correct? or would it be
cp a
ld a,(hl)
?
You don't need the cp part at all if you just want to set a to the value pointed to by hl... :/

cp a
ld a,(hl)

that would be somewhat equivalent to

IF a
THEN
END
(hl)[sto>]a
Oh I see. But what was Kerm talking about then? He said that ld was a conditional statement... 0.o?
swivelgames wrote:
Oh I see. But what was Kerm talking about then? He said that ld was a conditional statement... 0.o?
No I didn't; read my post more carefully and you'll see I said it is not a conditional statement. Smile
swivelgames wrote:
Oh I see. But what was Kerm talking about then? He said that ld was a conditional statement... 0.o?


You just epic failed at reading dude...
Nuu!! Ich bin eine Versagen! I phail, I phail with a capital ph.
Kllrnohj wrote:
cp a
ld a,(hl)

that would be somewhat equivalent to

IF a
THEN
END
(hl)[sto>]a

Except there isn't a condition anywhere in there. you'd need to do

Code:

 cp a   ;or a is more efficient, but this is just a demonstration
 jr z,_pass
 ld a,(hl)
_pass:
 ...

That comes out to Kllr's code. Remember that we're indirecting with HL, so if HL = $8000, A becomes the value that's at $8000 in memory.
The Tari wrote:
Kllrnohj wrote:
cp a
ld a,(hl)

that would be somewhat equivalent to

IF a
THEN
END
(hl)[sto>]a

Except there isn't a condition anywhere in there. you'd need to do

Code:

 cp a   ;or a is more efficient, but this is just a demonstration
 jr z,_pass
 ld a,(hl)
_pass:
 ...

That comes out to Kllr's code. Remember that we're indirecting with HL, so if HL = $8000, A becomes the value that's at $8000 in memory.


You fail too Razz The IF-THEN statement in my equivalent didn't contain any conditional code. Your ASM code is not equivalent to my Basic as your conditional contains the instructions ld a,(hl) - my Basic doesn't. Look over my code again
I guess the utter pointlessness of an empty IF statement threw me off. Razz
At any rate, how I did it is the sort of thing you'd do normally.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement