im trying to make something that simply loads HL with the contents in Ans. so far, this is what I have:


Code:

(Header)
Start:
 LD A,0
 LD (curRow),A
 LD (curCol),A
 BCALL RclAns
 LD HL,OP1
 BCALL DispHL
 RET


but the program always puts out the same number: "33912".

what did i do wrong?
DispHL displays the value of HL, not the thing/string/number it points to
EDIT: ninja'd

it prints that because HL is the location of OP1 in RAM, not the VALUE of it.
Reading Sticky: Indirection would help.

Also, OP1-6 are Floating point numbers, not integers. You need to convert it to be stored in Z80 registers.

The Bcall ConvOP1 is used for it. It puts whole OP1 in HL. it puts Least significant byte (LSB, LSB of 1234h is 34h) in A. It says ERR:OVERFLOW if > 65535.

the revised code


Code:
(Header) 
Start: 
 LD A,0 
 LD (curRow),A 
 LD (curCol),A 
 BCALL RclAns 
 LD HL,OP1 
 BCALL ConvOP1
 BCALL DispHL 
 RET
There's a B_CALL that will do this for you, although it expects Ans to be an integer from 0-9999: _ConvOP1. It'll convert OP1 to a value in DE, truncating decimals, ignoring the sign, throwing an invalid dim error if larger than 9999, and probably returning 0 if OP1 didn't contain a float.
argh, so thats why it didnt work. and to fix, i just put OP1 in "()"?

also, this is for a larger project where inputs should be Int 1-6 only. do i really need to convert OP1 to an int if i know it *should* be an Int?

Edit: Nope, i do need ConvOP1. thanks guys.
  
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 1 of 1
» 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