How do I load the value of OP1 back to a Variable?

Does this work?

Code:
 LD (GallionsRateInDollars),OP1


If I can't do this, then is this going to work?

Code:
 LD HL,OP1
 LD (GallionsRateInDollars),HL
Sorry about the late reply; was trying to see if you could work it out.

Tell me how this works:


Code:
ld hl,Op1
ld de,GallionsRateInDollars
ld bc,9
ldir


EDIT: Also, from many, many pages ago:

Imabian wrote:
It *does* work but you'll end up with a whole host of additional problems including managing stack levels and contents, which ends up becoming more difficult than simply copying the values to a chunk of safeRAM. If these are floating point values, you'll want to look into romcalls "MovFrOP1" (DE=ptr to location you want to store Op1) and "Mov9ToOP1" (HL=ptr to location you want to get contents of Op1). It may also be worth it to look up the romcall "Exch9".
No, that's not how it works. Op1 holds a floating point value, and your copying into the address pointed to by the first two bytes of the value at GallionsRateInDollars. I don't think you meant to add those indirection parentheses.

Edit: You corrected the error as I was posting. Smile
KermMartian wrote:
No, that's not how it works. Op1 holds a floating point value, and your copying into the address pointed to by the first two bytes of the value at GallionsRateInDollars. I don't think you meant to add those indirection parentheses.

Edit: You corrected the error as I was posting. Smile


So this works?

Code:
 LD HL,OP1
 LD GallionRateInDollars,HL
Ephraim B wrote:
KermMartian wrote:
No, that's not how it works. Op1 holds a floating point value, and your copying into the address pointed to by the first two bytes of the value at GallionsRateInDollars. I don't think you meant to add those indirection parentheses.

Edit: You corrected the error as I was posting. Smile


So this works?

Code:
 LD HL,OP1
 LD GallionRateInDollars,HL


No, no, no it does not. Not in the slightest sense of the imagination....

Please, I beg you once more, read the post directly above Kerm's. I accidentally copied the variable name with the parentheses, and it was just in response to that. Sorry if that was somewhat confusing....
MateoConLechuga wrote:
Sorry about the late reply; was trying to see if you could work it out.

Tell me how this works:


Code:
ld hl,Op1
ld de,GallionsRateInDollars
ld bc,9
ldir


I understand that

Code:
 LD BC,9

means something for the 9 bytes of the floating-point Variable.
But, I don't understand what LDIR is for.
And here's the link: http://z80-heaven.wikidot.com/instructions-set:ldir

Enjoy! Smile
How do I add .01 with a floating point number. b_call(_FPAdd) only adds the integer unless this works:

Code:
   LD   HL,GallionValue
   b_call(_Mov9ToOP1)
   ld   A,Add.01                          ; This is the value to add by
   b_call(_Mov9ToOP2)
   b_call(_FPAdd)

GallionValue:
   .db $00, $81, $10, $07, $00, $00, $00, $00, $00    ;10.07

Add.01:
   .db $00, $7F, $01, $00, $00, $00, $00, $00, $00    ;.01
How do I add up all 3 Variables?

Edit: I think I solved it:

Code:
   LD   HL,GallionRateInDollars
   b_call(_Mov9ToOP1)

   LD   HL,SickleRateInDollars
   b_call(_Mov9ToOP2)

   b_call(_FPAdd)

   LD   HL,KnutRateInDollars
   b_call(_Mov9ToOP2)

   b_call(_FPAdd)


Edit 2: Oh no! This is very bad. I inputted this:

and I got this output:
Why are you adding the rates? Shouldn't you be adding the total amount each one gives? Wink

Also, what do your variables look like?
MateoConLechuga wrote:
Why are you adding the rates? Shouldn't you be adding the total amount each one gives? Wink

Also, what do your variables look like?


I'm multiplying the Gallions input by the Gallions Variable that equals 10.07, multiplying the Sickles input by the Sickles Variable that equals .59, and multiplying the Knuts input by the Knuts Variable that equals .02.
Then I want to add the Gallions Variable, Sickles Variable, and the Knuts Variable to get the answer in Dollars.

Edit:

Code:
;---------Variables-----------

DollarsValue:

   .db 0

GallionsValue:

   .db 0

SicklesValue:

   .db 0

KnutsValue:

   .db 0

GallionRateInDollars:

   .db $00,$81,$10,$07,$00,$00,$00,$00,$00

SickleRateInDollars:

   .db $00,$7F,$59,$00,$00,$00,$00,$00,$00

KnutRateInDollars:

   .db $00,$7E,$20,$00,$00,$00,$00,$00,$00


Edit 2: Code where I multiply and add the Variables:

Code:
   LD   HL,GallionRateInDollars
   b_call(_Mov9ToOP1)

   LD   HL,(GallionsValue)

   b_call(_SetXXXXOP2)
   b_call(_FPMult)

   LD   HL,OP1
   LD   DE,GallionRateInDollars
   LD   BC,9
   LDIR

   LD   HL,SickleRateInDollars
   b_call(_Mov9ToOP1)

   LD   HL,(SicklesValue)

   b_call(_SetXXXXOP2)
   b_call(_FPMult)

   LD   HL,OP1
   LD   DE,SickleRateInDollars
   LD   BC,9
   LDIR

   LD   HL,KnutRateInDollars
   b_call(_Mov9ToOP1)

   LD   HL,(KnutsValue)

   b_call(_SetXXXXOP2)
   b_call(_FPMult)

   LD   HL,OP1
   LD   DE,KnutRateInDollars
   LD   BC,9
   LDIR

   LD   HL,GallionRateInDollars
   b_call(_Mov9ToOP1)

   LD   HL,SickleRateInDollars
   b_call(_Mov9ToOP2)

   b_call(_FPAdd)

   LD   HL,KnutRateInDollars
   b_call(_Mov9ToOP2)

   b_call(_FPAdd)
Okay, I've not tested this as of yet, but this seems to be your main problem:


Code:
 LD   HL,(KnutsValue)

   b_call(_SetXXXXOP2)


You are loading a one byte thing into a two-byte register pair, and then converting it. Everywhere you have something like this, load your variable into a one-byte register, and convert it using _SetxxOp1.


Code:
 ld   a,(KnutsValue)

   b_call(_SetXXOP1)
MateoConLechuga wrote:
Okay, I've not tested this as of yet, but this seems to be your main problem:


Code:
 LD   HL,(KnutsValue)

   b_call(_SetXXXXOP2)


You are loading a one byte thing into a two-byte register pair, and then converting it. Everywhere you have something like this, load your variable into a one-byte register, and convert it using _SetxxOp1.


Code:
 ld   a,(KnutsValue)

   b_call(_SetXXOP1)


I can't do this for the GallionsValue since chances are the input could be 100 or more. SicklesValue and KnutsValue it would for sure work. Will this work?
Umm... If that is the case, then why don't you just make your variables two bytes instead of one? Also, A single byte can hold values up to 255...
So why is the number 100 important?

Also, every time you save the value back, you are overwriting it...

Again, please, please, please read the manual already.
The Variables are going very weird:
So, knowing that every line on that screen above me is a rom call to ILine, I have no idea even where to begin with helping that out. Using a bunch of bcalls to draw things and compute is not ASM. It is just weird -looking BASIC. The only advice that I can give right now is that it is _SetXXOP1 not _SetXXXXOP2

EDIT: I said once that I will not give up on this topic, but it is really hard not to. We are nine pages in, and been at it for more than 40 days, and I feel that not too much progress has been had. Unless you try a little harder, and ask a relevant question that you cannot figure out with the internet or ASM in 28 days, I may or may not post here again. I apologize, but I need to keep my sanity. Thank you.
MateoConLechuga wrote:
So, knowing that every line on that screen above me is a rom call to ILine, I have no idea even where to begin with helping that out. Using a bunch of bcalls to draw things and compute is not ASM. It is just weird -looking BASIC.

I'm using the b_call(_ILine) as a placeholder until WizardC8 is feature-complete. After WizardC8 is feature-complete, i'll be working on the UI and that is when i'll take care of the b_calls.
MateoConLechuga wrote:
The only advice that I can give right now is that it is _SetXXOP1 not _SetXXXXOP2

b_call(_SetXXOP1) or b_call(_SetXXOP2) won't work for the Gallions Input because it says in the TI PDF that it only works for a value of 0-99.

MateoConLechuga wrote:
EDIT: I said once that I will not give up on this topic, but it is really hard not to. We are nine pages in, and been at it for more than 40 days, and I feel that not too much progress has been had. Unless you try a little harder, and ask a relevant question that you cannot figure out with the internet or ASM in 28 days, I may or may not post here again. I apologize, but I need to keep my sanity. Thank you.

I'm pushing myself too much because I want to get WizardC8 done already and move on.
Because I feel that I may have left some confusion, let me clear up some things:

There is _SetXXOP1 and _SetXXOP2, which both can be used depending on what you need.

If you want to use register a, which can hold a decimal number up to 255, and you load it into register l, you can use _SetXXXXOP2. Just load 0 to h first.

I wish you the best of luck, and good job on reading the documentation! Smile
How does this make sense? Only the Gallions input is working and displaying correctly, but the Sickles it displays a random answer for the Dollars, and Knuts it displays 0 for the Dollars.

Here's the code for it:

Code:
   LD   HL,GallionRateInDollars
   b_call(_Mov9ToOP1)

   LD   HL,(GallionsValue)

   b_call(_SetXXXXOP2)
   b_call(_FPMult)

   LD   HL,OP1
   LD   DE,GallionsValueRateInDollars
   LD   BC,9
   LDIR

   LD   HL,SickleRateInDollars
   b_call(_Mov9ToOP1)

   LD   A,(SicklesValue)

   b_call(_SetXXOP2)
   b_call(_FPMult)

   LD   HL,OP1
   LD   DE,SicklesValueRateInDollars
   LD   BC,9
   LDIR

   LD   HL,KnutRateInDollars
   b_call(_Mov9ToOP1)

   LD   A,(KnutsValue)

   b_call(_SetXXOP2)
   b_call(_FPMult)

   LD   HL,OP1
   LD   DE,KnutsValueRateInDollars
   LD   BC,9
   LDIR

   LD   HL,GallionsValueRateInDollars
   b_call(_Mov9ToOP1)

   b_call(_OP1ToOP2)

   LD   HL,SicklesValueRateInDollars
   b_call(_Mov9ToOP1)

   b_call(_FPAdd)

   b_call(_OP1ToOP2)

   LD   HL,KnutsValueRateInDollars
   b_call(_Mov9ToOP1)

   b_call(_FPAdd)

   LD   A,6
   b_call(_DispOP1A)


Edit: And the Main Menu Header disappears when I set Knuts to 1 or > and the Main Menu Header looks very weird when I set Sickles to 1 or >.
Ephraim B wrote:
MateoConLechuga wrote:
EDIT: I said once that I will not give up on this topic, but it is really hard not to. We are nine pages in, and been at it for more than 40 days, and I feel that not too much progress has been had. Unless you try a little harder, and ask a relevant question that you cannot figure out with the internet or ASM in 28 days, I may or may not post here again. I apologize, but I need to keep my sanity. Thank you.

I'm pushing myself too much because I want to get WizardC8 done already and move on.


I know that it can be hard to postpone a project you want done as soon as possible, but sometimes some projects are just too much for the programmer's current skills, especially in Z80 ASM. Don't wonder why most people start with Hello World and small ASM programs that sets lowercase ON (or guessing games in TI-BASIC).
  
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
» Goto page Previous  1, 2, 3 ... 8, 9, 10, 11  Next
» View previous topic :: View next topic  
Page 9 of 11
» 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