In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Johnson Rod wrote: continuing from http://forums.parallax.com/forums/default.aspx?f=15&m=146166 so i've implemented: Let B[n:0] the array of bits in the usual binary representation Let G[n:0] the array of bits in Gray code G[n]=B[n] for i=n-1 down to i=0 {G[i]=B[i+1] XOR B[i]} as DEVICE SX48, OSCXT2 FREQ 50_000_000 reset main ORG $0A binary DS 1 gray DS 1 mask DS 1 ax DS 1 bx DS 1 cx DS 1 watch ax,8,UBIN watch bx,8,UBIN watch gray,8,UBIN110111 watch binary,8,UDEC watch mask,8,UBIN main: mov gray, #%0010_0111 ;G 53 break mov binary, gray mov mask, #%0100_0000 clr cx movb gray.7, cx.0 top: mov w, binary mov ax, w mov bx, w clc rr ax and ax, mask and bx, mask xor ax, bx jz set_0 or binary, mask jmp next set_0: not mask and binary, mask not mask next clc rr mask sc jmp top stick: jmp stick ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=146196 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)