1. a couple of memory routines
- Posted by Hayden McKay <hmck1 at dodo.com.au> Sep 07, 2004
- 507 views
This is just a couple of memory routines I want to share. I feel that they should be in the tk_misc/tk_maths library.
function getBCDval(atom addr) integer temp temp = (and_bits(peek(addr), #FF) * #100) + and_bits(peek(addr+2), #FF) return remainder(temp, #100) + (floor(temp / #100) /10) end function function farPtr(atom addr) return and_bits(peek4u(addr), #FFFF) + (and_bits(peek4u(addr+2), #FFFF) * 16) end function function peek2u(atom addr) return and_bits(peek4u(addr), #FFFF) end function
2. Re: a couple of memory routines
- Posted by Hayden McKay <hmck1 at dodo.com.au> Sep 09, 2004
- 460 views
Oop's! A friend of mine pointed out an mistake in getBCDval() This one works correctly. function getBCDval(atom addr) integer temp temp = (and_bits(peek(addr), #FF) * #100) + and_bits(peek(addr+1), #FF) return remainder(temp, #100) + (floor(temp / #100) /10) end function function farPtr(atom addr) return and_bits(peek4u(addr), #FFFF) + (and_bits(peek4u(addr+2), #FFFF) * 16) end function function peek2u(atom addr) return and_bits(peek4u(addr), #FFFF) end function