This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 07 Jun 2003 12:45:24 pm    Post subject:

It is a stupid question, but how do you do to add A to B ?
You can't write "add B, A", but you can write "add A, B". So you'd certainly exchange A and B, but can't either !!!!!!!!!!! Neutral
So what could I write ??????? It is though something quite basic, isn't it ?

For exemple, how would you write this following BASIC program in ASM ???

Code:
For(F, 47, 0, -1)
Line(47+F, 0, 47+F, 62)
Line(47-F, 0, 47-F, 62)
End


I changed 47+F in

Code:
ld b, 47
add b, a; with "A" decremented in a loop


Do you have the solution to this problem ? o_O
thank you


Last edited by Guest on 07 Jun 2003 12:46:43 pm; edited 1 time in total
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 07 Jun 2003 01:25:02 pm    Post subject:

i would try this :
push af
ld b,47
add a,b
ld b,a
pop af

would that work for ur problem? just a thought...
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 07 Jun 2003 05:42:19 pm    Post subject:

Well so long as you don't need the accumulator for anything you could just.

ld b,47
add a,b
ld b,a

If you need the accumulator then use Adm. Wiggin's code.
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 07 Jun 2003 08:20:56 pm    Post subject:

from what i gather, he needs to keep a intact for the loop... if a were to die, then the loop would be messed up too...
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 08 Jun 2003 02:43:15 am    Post subject:

Maybe he would be interested in the djnz loop.

e.g.

ld b,8
loop
;do stuff 8 times
djnz loop
Back to top
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 08 Jun 2003 08:35:38 am    Post subject:

Thank you, I may use it one day, but for the moment, I've found another way.
Remember, I wanted to use that to do the equivalent of

Code:
For(F, 47, 0, -1)
Line(47+F, 0, 47+F, 62)
Line(47-F, 0, 47-F, 62)
End

The "F" of the For is "a", and the coordonates are b, c, d, e (h=0 : OFF, h=1 : ON)

But finally I used the equivalent of :

Code:
For(F, 47, 0, -1)
Vertical 47+F
Vertical 47-F
End

with OP1 for the abscisse of Vertical !

So thank you, but I will keep my way Wink (how to do then, if we can't change registers a, b, c, d, e, h)
thx


Last edited by Guest on 08 Jun 2003 02:46:04 pm; edited 1 time in total
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement