» Goto page Previous  1, 2, 3 ... , 9, 10, 11  Next
» View previous topic :: View next topic  
A lot of us start with something other than z80, actually. I am an Axe programmer when I program z80 calcs, myself.
I can't believe it! Even after following step-by-step what BrandonW told me last night, the Gallions, Sickles, and Knuts are still not adding.

Here's a drawing I made to make it easier for me to try to figure out what went wrong:


And here's the code:

Code:
   LD   HL,GallionRateInDollars
   b_call(_Mov9ToOP1)

   LD   HL,(GallionsValue)

   b_call(_SetXXXXOP2)
   b_call(_FPMult)

   b_call(_OP1ToOP3)

   LD   HL,SickleRateInDollars
   b_call(_Mov9ToOP1)

   LD   A,(SicklesValue)

   b_call(_SetXXOP2)
   b_call(_FPMult)

   b_call(_OP3ToOP2)

   b_call(_FPAdd)

   b_call(_OP1ToOP3)

   LD   HL,KnutRateInDollars
   b_call(_Mov9ToOP1)

   LD   A,(KnutsValue)

   b_call(_SetXXOP2)
   b_call(_FPMult)

   b_call(_OP3ToOP2)

   b_call(_FPAdd)

   LD   A,6
   b_call(_DispOP1A)


And here are the Variables:

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: Fixed! I had no clue that b_call(_FPMult) destroys OP3. The second I found that out, I switched from OP3 to OP4. I also had to define 2 bytes for GallionsValue instead of 1.
The answer is "3"
allynfolksjr wrote:
The answer is "3"


No, it's 42
Ephraim B wrote:
Edit: Fixed! I had no clue that b_call(_FPMult) destroys OP3. The second I found that out, I switched from OP3 to OP4. I also had to define 2 bytes for GallionsValue instead of 1.


Awesome! That's what we like to read Smile I hope you continue to fix the problems with WizardC8 as time goes on. Keep us updated!
May I ask why this is being done in Assembly? It seems like BASIC would be simpler and easier.
Unicorn wrote:
May I ask why this is being done in Assembly? It seems like BASIC would be simpler and easier.


Experience. It's already been done in TI-Basic in WizardC7.
Ah thank you for the clarification.
MateoConLechuga wrote:
Using a bunch of bcalls to draw things and compute is not ASM. It is just weird -looking BASIC.


This is the wrong attitude to have about bcall use. bcalls are often slow, and don't necessarily get into the algorithmic challenges of assembly language, but you still need to learn about register usage and memory locations and stuff like that. Training wheels for assembly, as it were.

Ephraim:
Good work with the debugging! You should be sure to read the documentation for bcalls that you use, to make sure you're aware of the side effects. It will save you a lot of time.
Great job Ephraim! I am really impressed by the progress that you have made on this on your own. You certainly have what it takes to learn assembly, and drawing diagrams is especially useful. Keep up the good work! Smile

MateoConLechuga wrote:

Using a bunch of bcalls to draw things and compute is not ASM. It is just weird-looking BASIC.


Well, you know, in the sense that bcalls can sometimes be more harmful than useful. But you do make a valid point! Smile

Ephraim: Assembly takes time. Don't try to learn too many things at one time. Just focus in, and you can do it! Smile
I'm trying to display a floating point number in large font in DollarsToGallions, but i'm having a hard time getting it to display. I want to know how to do Fix 2 in ASM.
Well floats are really not the way to go in z80, really. You should learn how to do 8.8 fixed point. It is a lot faster and easier to handle.
Why isn't the numbers incrementing and decrementing correctly and how did it switch to signed numbers?

Code:

Code:
   JP   item1UserInputDisplay   ; goto label item1UserInputDisplay

item1UserInputLoop:         ; label item1UserInputLoop

   b_call(_GetKey)         ; Waits for a key to be pressed

   CP   kUp         ; If the up arrow key is pressed,
   JR   Z,Increase      ; goto label Increase

   CP   kDown         ; If the down arrow key is pressed,
   JR   Z,Decrease      ; goto label Decrease

   CP   kEnter         ; If the Enter key is pressed,
   JP   Z,DollarsToGallionsResults ; goto label DollarsToGallionsResults.

   JR   item1UserInputLoop   ; Else, loop back to
               ; label item1UserInputLoop
Increase:            ; label Increase

   LD   HL,DollarsValue
   b_call(_Mov9ToOP1)
   LD   HL,OP1
   LD   H,0
   LD   L,A
   CP   255         ; If Register A=255,
   JR   Z,item1UserInputLoop   ; goto label item1UserInputLoop
   b_call(_FPAdd)

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

   JR   item1UserInputDisplay   ; goto label item1UserInputDisplay

Decrease:            ; label Decrease

   LD   HL,DollarsValue
   b_call(_Mov9ToOP1)
   LD   HL,OP1
   LD   H,0
   LD   L,A
   CP   0         ; If Register A=0,
   JR   Z,item1UserInputLoop   ; goto label item1UserInputLoop
   b_call(_FPSub)

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

item1UserInputDisplay:         ; label item1UserInputDisplay

   LD   A,23         ; 23->Register A
   LD   (penRow),A      ; Register A->(penRow)
   LD   A,45         ; 45->Register A
   LD   (penCol),A      ; Register A->(penCol)

   LD   HL,DollarsValue
   b_call(_Mov9ToOP1)

   LD   A,6
   b_call(_DispOP1A)

   JP   item1UserInputLoop   ; goto label item1UserInputLoop


Variables:

Code:
DollarsValue:

   .db $00,$80,$00,$00,$00,$00,$00,$00,$00


I get a very weird output. When I press the up arrow, it displays -1.26E9 and when I press the down arrow, it displays 1.26E9. How does that make sense and how do I fix this?
it appears that the first bit of the signed output, the one containing the sign, is switched. I don't claim to know assembly, but I'd start there.
Well, I said once that I would like you to try and figure it out for yourself, so I am just going to point out a couple of issues that I see right off the bat.


Code:
LD   HL,OP1
   LD   H,0
   LD   L,A
   CP   0         ; If Register A=0


This does not do what you think it does.

Neither does this:

Code:
LD   HL,OP1
   LD   H,0
   LD   L,A
   CP   255         ; If Register A=255,


The code above me makes no sense. You load a memory address into a two byte register, and if a is 255, which is not a part of this address, it jumps. Basically, it just sets h to 0 and l to whatever's in a. I can kind of see what you were trying to do though. Just make another variable and compare the bytes to each other inside of a loop. Or you can use _ConvOP1 and check from there, if that is what you need.


Code:
JP   item1UserInputLoop


Also, it really isn't a problem, but I would use jr instead of jp in this case. I ask you why though.
MateoConLechuga wrote:
Well, I said once that I would like you to try and figure it out for yourself, so I am just going to point out a couple of issues that I see right off the bat.


Code:
LD   HL,OP1
   LD   H,0
   LD   L,A
   CP   0         ; If Register A=0


This does not do what you think it does.

Neither does this:

Code:
LD   HL,OP1
   LD   H,0
   LD   L,A
   CP   255         ; If Register A=255,


The code above me makes no sense. You load a memory address into a two byte register, and if a is 255, which is not a part of this address, it jumps. Basically, it just sets h to 0 and l to whatever's in a. I can kind of see what you were trying to do though. Just make another variable and compare the bytes to each other inside of a loop. Or you can use _ConvOP1 and check from there, if that is what you need.


Code:
JP   item1UserInputLoop


Also, it really isn't a problem, but I would use jr instead of jp in this case. I ask you why though.


I'm still pretty confused. I want it to display 0.00 and pressing the up arrow will add 1 and the down arrow will subtract 1. Pressing the right arrow will move the arrow to add and subtract the decimal places. Can you please help me do this?

Edit: OMG! I completely forgot that b_call(_FPAdd) adds OP1+OP2. All I need to do is set a Variable equal to 1.00 to OP2.

Edit 2: Why is my value signed?

Edit 3: I asked this on IRC and they replied that floating-point Variables are always signed. I'm struggling getting the floating-point Variable to compare.
Do you mean "signed" or "negative"? Real numbers are always signed, meaning that they have the potential to be positive or negative. Compare that with umeisgned values, which can only be positive (or, I suppose, negative).
KermMartian wrote:
Do you mean "signed" or "negative"? Real numbers are always signed, meaning that they have the potential to be positive or negative. Compare that with umeisgned values, which can only be positive (or, I suppose, negative).


I mean signed. I'm struggling getting my floating-point Variable to not get below zero.
Ephraim B wrote:
KermMartian wrote:
Do you mean "signed" or "negative"? Real numbers are always signed, meaning that they have the potential to be positive or negative. Compare that with umeisgned values, which can only be positive (or, I suppose, negative).


I mean signed. I'm struggling getting my floating-point Variable to not get below zero.


I am not sure about that one, as you can check which byte of the number that you are on, and if that one is 0, then don't do anything. As for your other questions, I would really look into the following bcalls:

1)SetNum0
2)DecO1Exp --
3)IncO1Exp --
4)Minus1
5)Plus1

-- Denote important ones for what you need.

When working with floating point numbers, bcalls are generally okay. But usually in assembly, most generally it is avoided because in Basic it can pretty much do the same thing.
I'm still going to need to load OP1 to Register A to use CP
  
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 ... , 9, 10, 11  Next
» View previous topic :: View next topic  
Page 10 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