Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
About
Team
Rules
Stats
Status
Sitemap
Chat
Downloads
Forum
News
Our Projects
Major Community Projects
Recent Posts
Unread Posts
Replies
Tools
SourceCoder3
Other Things...
Omnimaga Radio
TI-83 Plus ASM File Unsquisher
Z80 Conversion Tools
IES TI File Editor
Free RAM areas
Comprehensive Getkeyr table
URL Shortener
Online Axe Tilemap Editor
Help
Contact Us
Change Request
Report Issue/Bug
Team
Articles
Members
View the memberlist
Search For Members
Buddies
Login
Register
Omnimaga
»
Forum
»
Calculator Community
»
TI Calculators
»
ASM
»
[z80 ASM] How do 8.8 maths work ?
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [z80 ASM] How do 8.8 maths work ? (Read 3990 times)
0 Members and 1 Guest are viewing this topic.
Matrefeytontias
Axe roxxor (kinda)
LV10
31337 u53r (Next: 2000)
Posts: 1982
Rating: +310/-12
Axe roxxor
[z80 ASM] How do 8.8 maths work ?
«
on:
December 30, 2012, 02:11:28 pm »
Hi guys,
I already know how to do 16-bits multiplication and division in z80 ASM, but how to extend them to 8.8 fixed point ?
In fact there are two questions in one : how do 8.8 work (guess the title) and how do I implement them ?
Thanks by advance
«
Last Edit: December 30, 2012, 02:11:53 pm by Matrefeytontias
»
Logged
/\ >< [- |_| _\~ [- /?
All of the TI-z80 screenshots that I will post, unless I specifically mention that it's not the case, will run at 6 MHz.
Always
. If you find that unbelievable, you should check the last link of my sig
Nerdiness
Projects :
[Ndless3.1] nKaruga
,
[Axe] Worms (yes !)
,
[Ndless 3.1] F-Zero TrackSpire (dropped)
,
[Ndless 3.1] nSpeedX 3D (paused)
,
[Ndless 3.1] nRayC, an easy-to-use raycasting (3D) engine in C for your Nspire ! (paused)
Proud author of :
[TI-8x] Jetpack 8x+
,
[TI-8x+] Gravity Walls
,
[ASM for Axe] AxeDCS axiom for Axe programmers
,
[TI-8x+] WiredWorks : a SolidWorks on your Ti-83+/84+ !
,
[TI-8x+] Super Crate Box
,
[Axe] IkarugaX, an awesomely challenging danmaku/shoot-them-up for your TI-83+/84+ !
,
[ASM for Axe] AxeJh3D axiom, a very fast 3D ASM library for Axe coders !
If at a certain moment you think that I'm awesome, you can express it by
giving me one more Internet (>^_^)>
jacobly
LV5
Advanced (Next: 300)
Posts: 205
Rating: +161/-1
Re: [z80 ASM] How do 8.8 maths work ?
«
Reply #1 on:
December 30, 2012, 03:53:27 pm »
Since 8.8 numbers are stored the same way as 16-bit integers, let x be the first value interpreted as an integer and y be the second value interpreted as an integer. Then x/256 is the first value interpreted as 8.8 and y/256 is the second value as 8.8. Additionally if z/256 is the result interpreted as an 8.8 value, then z mod 65536 is the result as a 16-bit integer.
z/256=x/256+y/256
z/256=(x+y)/256
z=x+y (Addition is exactly the same)
Spoiler
For
Example
:
add hl,de
z/256=x/256-y/256
z/256=(x-y)/256
z=x-y (Subtraction is exactly the same)
Spoiler
For
Example
:
or a
sbc hl,de
z/256=(x/256)*(y/256)
z/256=xy/65536
z=xy/256 (Multiplication result must be divided by 256)
Spoiler
For
Example
:
ld a,l
ld c,h
ld hl,0
ld b,16
Loop:
add hl,hl
rla
rl c
jr nc,Skip
add hl,de
adc a,0
Skip:
djnz Loop
ld l,h
ld h,a
ret
z/256=(x/256)/(y/256)
z/256=x/y
z=256x/y (First operand must be multiplied by 256)
Spoiler
For
Example
:
ld bc,16*256
ld a,l
ld l,h
ld h,c
Loop:
scf
rl c
rla
adc hl,hl
sbc hl,de
jr nc,Skip
add hl,de
dec c
Skip:
djnz Loop
ret
z/256=√(x/256)
z=√x/√256*256
z=√x/16 (Square Root result must be divided by 16)
Spoiler
For
Example
:
ld b,12
ld a,h
ld c,l
ld de,0
ld h,d
ld l,e
Loop:
sub $40
sbc hl,de
jr nc,Skip
add a,$40
adc hl,de
Skip:
ccf
rl e
rl d
sla c
rla
adc hl,hl
sla c
rla
adc hl,hl
djnz Loop
ex de,hl
ret
Of course, these are all unsigned. Changing to signed is almost identical to changing integer math to signed.
Edit:
Mixed up h and l at the beginning of the multiply routine.
«
Last Edit: December 30, 2012, 07:11:25 pm by jacobly
»
Logged
+2/-0 karm for this message
Matrefeytontias
Axe roxxor (kinda)
LV10
31337 u53r (Next: 2000)
Posts: 1982
Rating: +310/-12
Axe roxxor
Re: [z80 ASM] How do 8.8 maths work ?
«
Reply #2 on:
December 30, 2012, 04:03:42 pm »
Oh okay, it's in fact a multiplication/division involving a 24-bits number which is either for the multiplication the result or for the division the first operand. That's it ?
Logged
/\ >< [- |_| _\~ [- /?
All of the TI-z80 screenshots that I will post, unless I specifically mention that it's not the case, will run at 6 MHz.
Always
. If you find that unbelievable, you should check the last link of my sig
Nerdiness
Projects :
[Ndless3.1] nKaruga
,
[Axe] Worms (yes !)
,
[Ndless 3.1] F-Zero TrackSpire (dropped)
,
[Ndless 3.1] nSpeedX 3D (paused)
,
[Ndless 3.1] nRayC, an easy-to-use raycasting (3D) engine in C for your Nspire ! (paused)
Proud author of :
[TI-8x] Jetpack 8x+
,
[TI-8x+] Gravity Walls
,
[ASM for Axe] AxeDCS axiom for Axe programmers
,
[TI-8x+] WiredWorks : a SolidWorks on your Ti-83+/84+ !
,
[TI-8x+] Super Crate Box
,
[Axe] IkarugaX, an awesomely challenging danmaku/shoot-them-up for your TI-83+/84+ !
,
[ASM for Axe] AxeJh3D axiom, a very fast 3D ASM library for Axe coders !
If at a certain moment you think that I'm awesome, you can express it by
giving me one more Internet (>^_^)>
jacobly
LV5
Advanced (Next: 300)
Posts: 205
Rating: +161/-1
Re: [z80 ASM] How do 8.8 maths work ?
«
Reply #3 on:
December 30, 2012, 04:08:20 pm »
Pretty much
Logged
Matrefeytontias
Axe roxxor (kinda)
LV10
31337 u53r (Next: 2000)
Posts: 1982
Rating: +310/-12
Axe roxxor
Re: [z80 ASM] How do 8.8 maths work ?
«
Reply #4 on:
December 30, 2012, 06:09:26 pm »
It seems that your multiply routine doesn't work... I tried :
ld hl,$0180
ld de,$0200
call HLtimesDE88
bcall DispHL
It displayed 2 instead of 3.
Logged
/\ >< [- |_| _\~ [- /?
All of the TI-z80 screenshots that I will post, unless I specifically mention that it's not the case, will run at 6 MHz.
Always
. If you find that unbelievable, you should check the last link of my sig
Nerdiness
Projects :
[Ndless3.1] nKaruga
,
[Axe] Worms (yes !)
,
[Ndless 3.1] F-Zero TrackSpire (dropped)
,
[Ndless 3.1] nSpeedX 3D (paused)
,
[Ndless 3.1] nRayC, an easy-to-use raycasting (3D) engine in C for your Nspire ! (paused)
Proud author of :
[TI-8x] Jetpack 8x+
,
[TI-8x+] Gravity Walls
,
[ASM for Axe] AxeDCS axiom for Axe programmers
,
[TI-8x+] WiredWorks : a SolidWorks on your Ti-83+/84+ !
,
[TI-8x+] Super Crate Box
,
[Axe] IkarugaX, an awesomely challenging danmaku/shoot-them-up for your TI-83+/84+ !
,
[ASM for Axe] AxeJh3D axiom, a very fast 3D ASM library for Axe coders !
If at a certain moment you think that I'm awesome, you can express it by
giving me one more Internet (>^_^)>
jacobly
LV5
Advanced (Next: 300)
Posts: 205
Rating: +161/-1
Re: [z80 ASM] How do 8.8 maths work ?
«
Reply #5 on:
December 30, 2012, 07:11:54 pm »
Fixed.
Logged
Matrefeytontias
Axe roxxor (kinda)
LV10
31337 u53r (Next: 2000)
Posts: 1982
Rating: +310/-12
Axe roxxor
Re: [z80 ASM] How do 8.8 maths work ?
«
Reply #6 on:
December 30, 2012, 07:21:20 pm »
It works, thanks
(I think I could correct myself but it's 1 am
)
Logged
/\ >< [- |_| _\~ [- /?
All of the TI-z80 screenshots that I will post, unless I specifically mention that it's not the case, will run at 6 MHz.
Always
. If you find that unbelievable, you should check the last link of my sig
Nerdiness
Projects :
[Ndless3.1] nKaruga
,
[Axe] Worms (yes !)
,
[Ndless 3.1] F-Zero TrackSpire (dropped)
,
[Ndless 3.1] nSpeedX 3D (paused)
,
[Ndless 3.1] nRayC, an easy-to-use raycasting (3D) engine in C for your Nspire ! (paused)
Proud author of :
[TI-8x] Jetpack 8x+
,
[TI-8x+] Gravity Walls
,
[ASM for Axe] AxeDCS axiom for Axe programmers
,
[TI-8x+] WiredWorks : a SolidWorks on your Ti-83+/84+ !
,
[TI-8x+] Super Crate Box
,
[Axe] IkarugaX, an awesomely challenging danmaku/shoot-them-up for your TI-83+/84+ !
,
[ASM for Axe] AxeJh3D axiom, a very fast 3D ASM library for Axe coders !
If at a certain moment you think that I'm awesome, you can express it by
giving me one more Internet (>^_^)>
blue_bear_94
LV8
Addict (Next: 1000)
Posts: 801
Rating: +25/-35
Touhou Enthusiast / Former Troll / 68k Programmer
Re: [z80 ASM] How do 8.8 maths work ?
«
Reply #7 on:
December 30, 2012, 08:43:44 pm »
Try getting a 32-bit result, and take the middle 2 bytes.
Logged
Due to dissatisfaction, I will be inactive on Omnimaga until further notice. (?? THP hasn't been much success and there's also the CE. I might possibly be here for a while.)
If you want to implore me to come back, or otherwise contact me, I can be found on GitHub (bluebear94), Twitter (@melranosF_), Reddit (/u/Fluffy8x), or e-mail (if you know my address). As a last resort, send me a PM on Cemetech (bluebear94) or join Touhou Prono (don't be fooled by the name). I've also enabled notifications for PMs on Omnimaga, but I don't advise using that since I might be banned.
Elvyna (Sunrise) 4 5%
TI-84+SE User (
2.30 2.55 MP
2.43)
TI-89 Titanium User (3.10)
Casio Prizm User? (1.02)
Bag
東方ぷろの
Print
Pages: [
1
]
Go Up
« previous
next »
Omnimaga
»
Forum
»
Calculator Community
»
TI Calculators
»
ASM
»
[z80 ASM] How do 8.8 maths work ?