Hello Everyone,
I have 8 bytes of data I need to condense into one byte.
Each byte is either an 0xFF or a 0x00.
If the byte is 0, then the bit in temp1 would be 0, if the byte is 0xFF
then the corresponding bit in temp1 would be 1.
The 8 bytes of data are saved LSB first.
I want to correct that so the output byte is correct.
I can't figure out why I am getting 0x26 as the output when it should be
0x46.
I am using avrstudio to simulate. Any ideas where I am going wrong?
I can't see the problem however it may be obvious to someone.
Any help is greatly appreciated.
Here is the code:
; .nolist .include "m8def.inc" .list ; .def temp = r16 .def temp1 = r17 .def count = r18 .cseg .org 0 ;------------------------------------------------------- Reset: rjmp Start ; ;------------------------------------------------------- Start: ldi temp,LOW(RAMEND) ; out SPL, temp ; ldi temp,HIGH(RAMEND) ; out SPH, temp ; ldi ZH,HIGH(HexData*2) ldi ZL, LOW(HexData*2) ldi count,8 clr temp1 Loop: lpm temp,Z+ ;get one byte lsr temp ;Shift bit 0 to C ror temp1 ;C to bit 7 dec count ;8 bytes to make one byte brne Loop ;------------------------------------------------------- stop: rjmp stop HexData: ;LSB ;MSB ;byte = 64 (output must be 46, MSB corrected) ; 0 1 1 0 0 1 0 0 .db 0x00,0xFF,0xFF,0x00,0x00,0xFF,0x00,0x00 .exit