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
bananaman
Indestructible


Calc Guru


Joined: 12 Sep 2005
Posts: 1124

Posted: 23 Nov 2008 09:44:27 pm    Post subject:

If I am not mistaken SetXXOP1 will only accept values from a between 0..99

Here is my code...

Code:
ld a,(type1)
inc a
ld b,a
sla a
add a,b
bcall(_SetXXOP1)
ld a,1
ld de,20*256 + 70
ld (pencol),de
bcall(_DispOp1a)

For some reason, when I know that (type1)==5, this routine is giving me an ERR:OVERFLOW, but a should only be 18 when the routine is called. Can anyone explain this phenomenon?

Edit:
I tried to simplify it to

Code:
ld a,18
bcall(_SetXXOP1)

and it still didn't work. This is really confusing me.


Last edited by Guest on 23 Nov 2008 10:14:13 pm; edited 1 time in total
Back to top
bananaman
Indestructible


Calc Guru


Joined: 12 Sep 2005
Posts: 1124

Posted: 23 Nov 2008 11:00:36 pm    Post subject:

I figured out how to get around this.

I wrote my own routine that displays the value of a to the current pencol / penrow


Code:
;========================
; disp_a
;------------------------
; input: a, num to display
;        current pencol / penrow
; destroys: all but hl
;========================
disp_a:
; if we take the number and modulo 10 and push that number onto the stack and then repeat with a / 10 until a is 0
; we will have them available to pop in the correct order
; we will count the number of numbers in b
   ld   b,0    ; keep track of amount of digits
disp_a_loop1:
   ld   c,0    ; keep track of a / 10
disp_a_loop2:
   sub   10
   jr   c,disp_a_mod
   inc   c
   jr   disp_a_loop2
disp_a_mod:
   inc   b
   add   a,58    ; a was too far down, and 48 will offset with ascii
   ld   e,a
   push   de    ; push ascii digit onto the stack
   ld   a,c
   cp   0
   jr   z,disp_a_disp
   jr   disp_a_loop1
disp_a_disp:
   pop   de
   ld   a,e
   bcall(_vputmap)
   djnz   disp_a_disp
   ret


I'm sorry for the double post, but I think that this should be placed in here for posterity. If anyone else can think of way to optimize this for speed, I would be happy.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 24 Nov 2008 12:26:08 am    Post subject:

what's wrong with using _SetXXXXOP2?
Back to top
bananaman
Indestructible


Calc Guru


Joined: 12 Sep 2005
Posts: 1124

Posted: 24 Nov 2008 07:02:41 am    Post subject:

Nothing, but most of the numbers that I am working with will be less than 99 so I should be able to use SetXXOP1, but for some reason, even when I try to set 18 to OP1, I get an error.
Back to top
benryves


Active Member


Joined: 23 Feb 2006
Posts: 564

Posted: 24 Nov 2008 07:38:11 am    Post subject:

DispOP1A displays 'A' digits, so if A is 1 and you try and display 18 you'll get the overflow error. Set A to something suitably large before calling DispOP1A.
Back to top
bananaman
Indestructible


Calc Guru


Joined: 12 Sep 2005
Posts: 1124

Posted: 24 Nov 2008 11:00:58 am    Post subject:

Ahhhh, thank you. That explains my problem. I was under the impression that it displayed a decimals not digits.
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