MateoConLechuga wrote:
Please, read my post one more time. Don't worry about decimals just yet. They can be strange at first. Just display a point in between the decimal and the whole number, sort of like a pseudo-decimal number. This will make math many times easier if that is what you are planning, and you will be able to understand what is happening better. Look at the BEST link for bcalls, but remember, bcalls are just locations that the program jumps too. You can pretty much create your own versions as well.

EDIT: If you want to move in between each place value, just multiply by 10 each time you move left. For example, to change 4.99 to 5.09, I could add 10 to the number. From 5.09 to 4.09, I could subtract 100.

By the way, before it might happen, a register cannot hold a decimal.


How do I display a point between the decimal and the whole number?

Edit: How do I make a number 2 decimal places (0.00) no matter what the number is? In TI-Basic, it was Fix 2.
Again, I point you to the post that I made on the 22nd of November. If you are unsure of how to display a point, then use your resources and look it up. I am not going to help you in this case, as it requires like two lines of code, and looking at my previous posts. Smile
What's the proper way of making decimal numbers. I know that there are b_call's to add, subtract, multiply, and divide decimal numbers.

Edit: How do I do the 2 decimal fixed point?
Please, I beg you, for all that is good, read my posts. Don't get too confused just yet. Read, learn, read some more, learn some more. This is not Basic. Smile

I know that you know there are bcalls to do all of the things that you would like to do, which makes me question why you would want to do this in assembly. Bcalls are most often used by the Basic Parser...
This is ridiculously confusing just to make a decimal number:

Code:
 .DB    $00, $80, $27, $18, $28, $18, $28, $45, $94    ;2.7182818284594


Can someone please make me understand this better?
This is a floating-point number with a BCD mantissa. The exact format of such floating-point numbers for the TI-Z80 series is documented at multiple places.
Ephraim B wrote:
Can someone please make me understand this better?


Don't think that anyone can "make" you understand... But here's an explanation:

The first byte tells you the sign. The second byte tells you the exponent, or in other words, the location of the decimal. Everything afterwords is the number itself. This is all located here: http://tutorials.eeems.ca/ASMin28Days/lesson/day18.html

I am not against using the FP operations provided by the calculator, I just consider the alternative ways of doing some things. I guess the point way just makes more sense to me, even though technically there are many ways of doing the same thing. Smile
MateoConLechuga wrote:
Ephraim B wrote:
Can someone please make me understand this better?


Don't think that anyone can "make" you understand... But here's an explanation:

The first byte tells you the sign. The second byte tells you the exponent, or in other words, the location of the decimal. Everything afterwords is the number itself. This is all located here: http://tutorials.eeems.ca/ASMin28Days/lesson/day18.html

I am not against using the FP operations provided by the calculator, I just consider the alternative ways of doing some things. I guess the point way just makes more sense to me, even though technically there are many ways of doing the same thing. Smile


$00 means positive. Is that true
The second byte is pretty confusing since $2 does not do 2 decimal places. So, what goes there for the exponent?
Since links don't appear to be your strong suit, I give you this:

ASM in 28 Days wrote:
Sign
This byte determines if the number evaluates as positive or negative, and also if it is real or complex. For the uninitiated, a complex number is one of the form a+bi, where i is the square root of -1.
%00000000 — Positive and real.
%10000000 — Negative and real.
%00001100 — Positive and complex.
%10001100 — Negative and complex.
Exponent
The exponent field reports the power of ten that the mantissa is to be raised. The number format is not the usual two's complement, but rather biased to $80. A value of $80 translates as 10^0. $81 is 10^1. $7F is 10^-1.


There is no two decimal places idea, rather, it is based on exponents. To use decimals you could change the Fix flag, but then your program is mostly just long list of bcalls.
MateoConLechuga wrote:
Since links don't appear to be your strong suit, I give you this:

ASM in 28 Days wrote:
Sign
This byte determines if the number evaluates as positive or negative, and also if it is real or complex. For the uninitiated, a complex number is one of the form a+bi, where i is the square root of -1.
%00000000 — Positive and real.
%10000000 — Negative and real.
%00001100 — Positive and complex.
%10001100 — Negative and complex.
Exponent
The exponent field reports the power of ten that the mantissa is to be raised. The number format is not the usual two's complement, but rather biased to $80. A value of $80 translates as 10^0. $81 is 10^1. $7F is 10^-1.


There is no two decimal places idea, rather, it is based on exponents. To use decimals you could change the Fix flag, but then your program is mostly just long list of bcalls.


The first byte I understand.
The second byte I still don't understand that much even after looking at ASM in 28 days with day 18 being printed out. Can you please show me an example of what 10.07 would be? I think that i'll understand it better if you do.

Edit: This is all I could think of to make 10.07:

Code:
 .db $00,[i'm not sure what goes here],$10,$07
You're on the right track, but missing some pieces:

Code:

.db $00,$81,$10,$07,[lots of zeroes go here]


Look at the second byte and subtract $7F from it. This will give you a number in hexadecimal. Convert it to decimal, and count that many digits over to see where the decimal is placed. So for example, $81 - $7F = $02, which is still 2 in decimal. So $10,$07 can be interpreted as 10.07. If you had $80 instead of $81, it would be 1.007, and if you had $82 instead, it would be 100.7.
elfprince13 wrote:
You're on the right track, but missing some pieces:

Code:

.db $00,$81,$10,$07,[lots of zeroes go here]


Look at the second byte and subtract $7F from it. This will give you a number in hexadecimal. Convert it to decimal, and count that many digits over to see where the decimal is placed. So for example, $81 - $7F = $02, which is still 2 in decimal. So $10,$07 can be interpreted as 10.07. If you had $80 instead of $81, it would be 1.007, and if you had $82 instead, it would be 100.7.


Will this work for a Variable to equal 10.07?

Code:
GallionValueInDollars:

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


If it does then all I have to do is (GallionValueInDollars) times (DollarsValue)
How do I do that?
Okay, so to work with floating point numbers, rather than direct assembly, which does tend to be slower, but I guess it really doesn't matter, this is how you would do that:


Code:
; (C) Matt Waltz
; Multiplys 10.07 by something else -- Is customizable

.nolist
#include "ti83plus.inc"
.list

.org   $9D93
.db   $BB,$6D

ProgramStart:
   b_call(_ForceFullScreen)
   b_call(_GrBufClr)
   b_call(_GrBufCpy)
   set 7,(iy+20)
   res 2,(iy+50)
   
   ld de,1               ; Set initial coordinates
   ld (pencol),de
   
   ld   hl,GallionValue
   b_call(_Mov9ToOP1)
   ld   a,5                             ; This is the value to multiply by
   b_call(_SetXXOP2)
   b_call(_FPMult)
   
   ld a,$06
   b_call(_dispop1a)
   b_call(_GrBufCpy)
   ret
   
GallionValue:
   .db $00, $81, $10, $07, $00, $00, $00, $00, $00    ;10.07


Notice how instead of _FPMult, you can call a whole variety of bcalls. Please note however, that my earlier suggestion would also work in the same idea, but now it might be easier. Does this code make sense?
MateoConLechuga wrote:
Okay, so to work with floating point numbers, rather than direct assembly, which does tend to be slower, but I guess it really doesn't matter, this is how you would do that:


Code:
; (C) Matt Waltz
; Multiplys 10.07 by something else -- Is customizable

.nolist
#include "ti83plus.inc"
.list

.org   $9D93
.db   $BB,$6D

ProgramStart:
   b_call(_ForceFullScreen)
   b_call(_GrBufClr)
   b_call(_GrBufCpy)
   set 7,(iy+20)
   res 2,(iy+50)
   
   ld de,1               ; Set initial coordinates
   ld (pencol),de
   
   ld   hl,GallionValue
   b_call(_Mov9ToOP1)
   ld   a,5                             ; This is the value to multiply by
   b_call(_SetXXOP2)
   b_call(_FPMult)
   
   ld a,$06
   b_call(_dispop1a)
   b_call(_GrBufCpy)
   ret
   
GallionValue:
   .db $00, $81, $10, $07, $00, $00, $00, $00, $00    ;10.07


Notice how instead of _FPMult, you can call a whole variety of bcalls. Please note however, that my earlier suggestion would also work in the same idea, but now it might be easier. Does this code make sense?


I want to avoid dealing with the buffer until I get more advanced in ASM
Okay, without a buffer: Wink


Code:
   ld   hl,GallionValue
   b_call(_Mov9ToOP1)
   ld   a,5                             ; This is the value to multiply by
   b_call(_SetXXOP2)
   b_call(_FPMult)
GallionValue:
   .db $00, $81, $10, $07, $00, $00, $00, $00, $00    ;10.07
MateoConLechuga wrote:
Okay, without a buffer: Wink


Code:
   ld   hl,GallionValue
   b_call(_Mov9ToOP1)
   ld   a,5                             ; This is the value to multiply by
   b_call(_SetXXOP2)
   b_call(_FPMult)
GallionValue:
   .db $00, $81, $10, $07, $00, $00, $00, $00, $00    ;10.07


Thank you. Now all I have to do is replace

Code:
 LD A,5

with

Code:
 LD A,(GallionsValue)


GallionsValue is the Variable where the number of Gallions the user decided to select.

GallionValue is a horrible name for that label due to it being used for something else, so, I'm going to name that label to something else.
Yes, you are indeed correct. But one thing that I would like to point out is that code that I gave you the second time is the same exact code I gave you the first time. Smile

See, now you are starting to get the hang of things! Smile
A Sickle is worth $0.59.

Does this Variable work?

Code:
SickleInDollarsRate:

 .db $00,$80,$05,$90,$00,$00,$00,$00,$00


I have a good feeling it does. I'm now going to need to add the Variable with the value of 10.07 and the Variable with 0.59.

A Knut is worth $0.02.

Does this Variable work?

Code:
KnutInDollarsRate:

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


I have a good feeling it does. I'm going to need to also add this Variable to the other 2 Variables.
EDIT: Whoops, read those wrong. Yes, those should work in theory, but generally you would want to write them like this:


Code:
SickleInDollarsRate:

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



Code:
KnutInDollarsRate:

 .db $00,$7E,$20,$00,$00,$00,$00,$00,$00
MateoConLechuga wrote:
EDIT: Whoops, read those wrong. Yes, those should work in theory, but generally you would want to write them like this:


Code:
SickleInDollarsRate:

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



Code:
KnutInDollarsRate:

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


Would it still Multiply, Divide, Add, or Subtract correctly?

Edit:

Code:
12:28:38 (C) MateoConLechuga: Ephraim: Yes. :)
  
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 ... 7, 8, 9, 10, 11  Next
» View previous topic :: View next topic  
Page 8 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