Re: 8051 Programming
- From: "petrus bitbyter" <pieterkraltlaatditweg@xxxxxxxxxxxxxxxxx>
- Date: Tue, 14 Nov 2006 22:12:02 +0100
"petrus bitbyter" <pieterkraltlaatditweg@xxxxxxxxxxxxxxxxx> schreef in
bericht news:4557bdb1$0$26967$e4fe514c@xxxxxxxxxxxxxxxxxxxxxxxxxxx
<luisdanielsilva@xxxxxxxxx> schreef in bericht
news:1163360427.487718.18100@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I need to convert a 32 bit binary number to gray code. i know how to do
it bit by bit, but i need to do a function to do it, so that i don't
need to repeat code 32 times. Can anybody help me?
Thanks
LDS
Mmm... It's quite some time I wrote 8051 assembler, but if memory serves
it's done like this:
num1 equ 64
num2 equ 65
num3 equ 66
num4 equ 67
clr c
mov a,num1
rlc a
xrl a,num1
mov a,num2
rlc a
xrl a,num2
mov a,num3
rlc a
xrl a,num3
mov a,num4
rlc a
xrl a,num4
end
petrus bitbyter
Oops,
Memory fails. The next code should be correct:
num1 equ 64
num2 equ 65
num3 equ 66
num4 equ 67
clr c
mov a,num1
rlc a
xrl num1,a
mov a,num2
rlc a
xrl num2,a
mov a,num3
rlc a
xrl num3,a
mov a,num4
rlc a
xrl num4,a
end
petrus bitbyter
.
- References:
- 8051 Programming
- From: luisdanielsilva
- Re: 8051 Programming
- From: petrus bitbyter
- 8051 Programming
- Prev by Date: Re: No voltage across power out terminals and speaker playing
- Next by Date: Re: Sounds from IS
- Previous by thread: Re: 8051 Programming
- Next by thread: Digikey search
- Index(es):
Relevant Pages
|