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: 18 Sep 2003 01:38:20 pm    Post subject:

I'd like to code a highscore on 16 bits instead of 8.
So that's how I would declare the score :

score .dw 0


Which will create "00 00". Allright. Now, I want to increment it (for exemple, it is equal to FF. But is it "00 FF" or "FF 00" ?). That's how I would increment it :


ld a, (score)
ld h, a
ld a, (score+1)
ld l, a

inc hl
ld (score), hl


Is that right or is there any other way to do it ?
Last question : is it possible to display its value by doing :

ld a, (score)
ld h, a
ld a, (score+1)
ld l, a

B_CALL(_setxxxxop2)
B_CALL(_op2toop1)
B_CALL(_dispop1a)


Thanks for answering Smile
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 18 Sep 2003 02:32:48 pm    Post subject:

:?

ld hl,(score)
inc hl
ld (score),hl
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 18 Sep 2003 04:08:31 pm    Post subject:

does bcall(_setxxxxop1) use hl, or de? might want to look that up if u dont know already...
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 18 Sep 2003 10:16:11 pm    Post subject:

Adm. Wiggin;

bcall(_setxxxxop2) sets op2 to a floating point integer between 0 and 65535 using hl as the input.
Back to top
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 19 Sep 2003 12:14:31 am    Post subject:

That's it Justin.

Sigma, I don't agree with you :
By doing "ld hl, (score)", you only store the first byte in (hl).
By doing "inc hl", you just move the pointer, which will point the next byte.
Then, that's the worst, you put the address (for exemple 9E50h) in score and score+1 !!!
So this ode won't work ;-)


Nobody knows how to do ?
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 19 Sep 2003 01:14:01 am    Post subject:

Actually what Sigma wrote will work fine.

Here is some code:


Code:
IncreaseScore:
   ld hl,(Score)         ;hl -> Score
   inc hl                ;hl -> hl + 1
   ld (Score),hl         ;Score -> Score + 1

DisplayScore:
   ld hl,(0*256)+22      ;penrow = 0, pencol = 22
   ld (pencol),hl        ;set those coords
   ld hl,(Score)         ;Score -> hl
   bcall(_setxxxxop2)    ;hl -> op2
   bcall(_op2toop1)      ;op2 -> op1
   ld a,4                ;max # of chars to display
   bcall(_dispop1a)      ;display op1 (Score) at penrow, pencol


:)


Last edited by Guest on 19 Sep 2003 01:21:19 am; edited 1 time in total
Back to top
CoBB


Active Member


Joined: 30 Jun 2003
Posts: 720

Posted: 19 Sep 2003 06:56:49 am    Post subject:

Tyraniek wrote:
Sigma, I don't agree with you :
By doing "ld hl, (score)", you only store the first byte in (hl).
By doing "inc hl", you just move the pointer, which will point the next byte.
Then, that's the worst, you put the address (for exemple 9E50h) in score and score+1 !!!
So this ode won't work Wink

This is the most hilarious thing I've read today. You are given the correct solution and you turn it down as if it was erroneous... Probably you should try it first and consult a z80 instruction reference before posting such responses.
Back to top
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 19 Sep 2003 08:35:39 am    Post subject:

Yes, I'm really confused !!!!
I mistook "ld hl, score" with "ld hl, (score)".

I apologize Sigma. I just noticed it when I left my home. Then I could not edit my post any more.

Really sorry, and thank you for your help.
I apologize.
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 19 Sep 2003 06:04:22 pm    Post subject:

CoBB wrote:
This is the most hilarious thing I've read today.

No it isn't, this is Smile

Before:

Code:
Msg1:
  LD  A,'A'
  JP  Display
Msg2:
  LD  A,'E'
  JP  Display
Msg3:
  LD  A,'Q'
  JP  Display
Msg4:
  LD  A,'X'
  JP  Display


After:

Code:
Msg1:
  LD  A,'A'
.DB  1
Msg2:
  LD  A,'E'
.DB  1
Msg3:
  LD  A,'Q'
.DB  1
Msg4:
  LD  A,'X'

Display:
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