please dont rip this site

SX Microcontroller Radix Math Method

Parsing the radix from "B" for binary, etc..

;by James Newton and Nikolai Golovchenko

;Enter with an ASCII character representing the desired base for a radix conversion. 
;B=Binary
;D=Decimal
;H=Hex
;O=Octal
;
;Challenge 1: exit with a different bit set for each base.
;Challenge 2: exit with the radix (2 for binary, 10 for decimal, 16 for hex, 8 for octal)
;Challenge 3: exit with a jump table index
;
;My best:

	Radix		ds 1	;radix to change data from
RadixBin	=	Radix.1	;B  01000011
RadixOct	=	Radix.4	;O  01010000
RadixDec	=	Radix.2	;D  01000101
RadixHex	=	Radix.3	;H  01001001

Answer1
	inc	radix	;B=3,D=5,H=9,N=15,O=16
;done
	jb	radix.0, binary
	jb	radix.1, decimal
	jb	radix.2, hex
	jb	radix.3, octal

Answer2
	inc	radix
	clrb	radix.6	;B=3,D=5,H=9,O=16
	sb	radix.2	;if not D (5)
	 dec	radix	;B=2,D=5,H=8,O=15
	snb	radix.1	;if D or H
	 rl	radix	;B=2,D=11,H=17,O=15
	clrb	radix.0	;B=2,D=10,H=16,O=14
	snb	radix.2	;if O
	 clrb	radix.1	;B=2,D=10,H=16,O=12
	clrb	radix.2	;B=2,D=10,H=16,O=8

;or...
	
	inc	radix
	mov	w, #2
	snb	RadixOct
	 mov	w, #8
	snb	radixDec
	 mov	w, #10
	snb	radixHex
	 mov	w, #16

;and if you want to handle N = nibble

	inc	radix
	mov	w, #8
	snb	radixDec
	 mov	w, #5		;D or N
	snb	radixHex
	 mov	w, #16	;H
	snb	radixBin
	 mov	w, #2		;B or N
	snb	radixDec
	 rl	radix	
;if both .0 and .1 were set radix = 4
;if only .1 was set radix = 10

Answer3
	clrb	radix.6
	dec	radix	;B=2,D=5,H=8,O=15
	clc
	rr	radix	;B=1,D=2,H=4,O=7
	dec	radix	;B=0,D=1,H=3,O=6
	clb	radix.2	;B=0,D=1,H=3,O=2

file: /Techref/scenix/lib/math/radix/parseradix-jn_sx.htm, 1KB, , updated: 2004/6/10 13:40, local time: 2024/12/22 06:56,
TOP NEW HELP FIND: 
18.117.119.34:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/techref/scenix/lib/math/radix/parseradix-jn_sx.htm"> Parsing the radix from "B" for binary, etc..</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .