Vasile Surducan wrote: > Ok, I hate C ! Maybe you help me and translate this "ugly code": Why do you hate C ? What did it do to you ? //read byte from SPI (mode 3) as a master ;BYTE rdSPI(void) ;{ SrsSPI: ; register BYTE BitCnt = 8; counter 8 bit movlw 8 movwf BitCnt ; register BYTE Shift; auxiliary register ;; somewhere a register Shift is declared (cblock etc) ; do begin ? rsSPI_L0: ; { ; SPI_SCK_LO(); spi_sclk_lo = low ? bcf Fspi,Bspiclk ;; just guessing (plp) ; Shift <<= 1; asm rlf shift ? rlf Shift,f ; if(IS_SPI_SDI_LO()) movlw IS_SPI_SDI_LO_MASK ;; one bit set to select andwf Fspi,w ;; Z if LO btfss STATUS,Z goto rsSPI_L1 ; Shift &= ~1; this one is the hell thing !!! movlw 1 ;; deliberately not optimized so you can xorlw 0xFF ;; see it (plp) andwf Shift,f goto rsSPI_L2 ; else rsSPI_L1: ; Shift |= 1; same this one ! movlw 1 ;; hehe iorwf Shift,f rsSPI_L2: ; SPI_SCK_HI(); bsf Fspi,Bspiclk ;; just guessing (plp) ; } while (--BitCnt); ok here repeat 8 times decfsz BitCnt,f goto rsSPI_L0 ;} return 0 There are other more efficient ways to write the assembly. The compiler would probably outdo me easily ;-). If you are confused by a compound expression rewrite it as several simpler expressions like: Shift &= ~1; tmp = ~1; tmp1 = Shift & tmp; Shift = tmp; ~1 is the 1's complement of 1 on the domain Shift it defined on (i.e. a Byte), thus ~1 is 0xFF-1 = 0xFE. When you see something like = in C it simply means: = ; = ; Peter -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads