On Monday, May 24, 2004, at 20:25 US/Pacific, Rafael Vidal Aroca wrote: > It's part of picnic project (http://picnic.sf.net) - in the file > webpic.asm > > This code receives an ISA_OFFSET to address an register inside an > ISA board that is connected to the pic. > ISA_HBASEIO and ISA_LBASEIO are the 2 bytes that makes the fixed >> Yuck. It looks like the difficulty is because the address bus (if I'm reading the rather unlabled schematic correctly) is split across the 6 low bits of portC (low bits?) and 4 high bits bits of portb. >> i'm having trouble converting this asm code that runs on a pic >> 16F877 to CCS C. I tried to convert it, but it did not work :( >> >> I'd be really thankful if anyone could translate this code into C >> so that i can compare with what i did. >> >> movlw ISA_HBASEIO >> movwf ISA_HADR >> >> movf ISA_OFFSET, W >> addlw ISA_LBASEIO >> movwf ISA_LADR >> this computes the actual address: ISA_HADR = ISA_HBASEIO; ISA_LADR = ISA_OFFSET + ISA_LBASEIO; That was obvious enough. >> ; parse address >> >> movf ISA_LADR, W >> andlw 0x3F >> movwf PORTC PORTC = ISA_LADR & 0x3F; Now we get into interesting "logic." >> rrf ISA_LADR, F >> rrf ISA_LADR, W >> andlw 0x30 >> movwf ISA_LADR This takes the two bits that we didn't send to portC, and puts them in the 0x30 position in W (and ISA_LADR, which .. isn't, anymore.) I'd rewrite it (from a pure C point of view) ISA_LADR = (ISA_LADR & 0xC0) >> 2; >> >> swapf ISA_HADR, F >> rlf ISA_HADR, F >> rlf ISA_HADR, W >> andlw 0xC0 >> movwf ISA_HADR this puts the two low bits of ISA_HADR in the C0 bit positions of W and ISA_HADR. the rest of ISA_HADR goes away... ISA_HADR = (ISA_HADR & 0x3) << 6; >> >> >> movlw 0x0F >> addwf ISA_LADR, W >> addwf ISA_HADR, W >> movwf PORTB I'm not sure what they're doing with the low bits of portB, but I see: PORTB = 0xF + /* Low bits */ ISA_LADR + /* 0x30 bits */ ISA_HADR; /* 0xC0 bits */ Is that more or less what you came up with? BillW -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu