From: cclist at
sydex.com
Date: Fri, 18 Jan 2008 18:20:45 -0800
From: dwight elvey
For this, I need a little help. Since the 8 inch
drives were 32 sectored,
calculating tracks from a disk offset number was easy. 5.25 disk with 10
sectored will require something different. Is there an easy way to to
separate track from sector using Z80 code? Dwight
Do you mean "is there an easy way to divide by 10?". If so, yes:
0.100x = x/16+x/32+x/256+x/4096+x/8192
to about 0.04 percent (4 parts in 10,000). Truncate the series if
you need less accuracy. Ask if you need Z80 code.
Cheers,
Chuck
Hi Chuck
I'm not sure how effective that would be in Z80 code. It looks
like I'd at least need to do 32 bit coding to keep track of things.
I'd still need to calculate the remainder when done( I need both ).
The maximum sector index would be 800 decimal. I came up
with the following code to do this all in Z80 code but I'm interested
both compact and fast, with more emphasis on compact.
Here is the code I've made so far:
; hl is value to be divided by 10
; max hl will be 800
; uses a, bc, de and hl
; returns a = quotient
; h = remainder
; uses 42 bytes
div10:
xor a
ld bc -640d
ld de 640d
call div10s
call div10s
call div10s
call div10s
call div10s
call div10s
call div10s
add hl,hl
ret
div10s:
add a,a
add hl,bc
jp c,div10s1
add hl,de
jp div10s2
div10s1:
inc a
div10s2:
add hl,hl
ret
After the first two calls, I could do the rest as byte operations
but I think the total byte cost would be greater.
I'm looking for other ideas on smaller code. It would be nice
to hace one more 8 bit register as a counter.
Dwight
_________________________________________________________________
Shed those extra pounds with MSN and The Biggest Loser!
http://biggestloser.msn.com/