Hi Doland, The program is perfectly fine. The simulation is producing the expecting result as well. How are you simulating the program?
You should not call the assembler or linker explicitly. Let it be called by sdcc itself. Krish On Wed, Mar 23, 2011 at 10:26 PM, duck donal <tangtao87657...@gmail.com> wrote: > Hi roelof, > Thank u for ur advices! > I have a new trouble with simulating the .hex code on my 8051. > The newpp.hex according to the newpp.c(as follow): > //newpp.c > #include <AT89X51.H> > #include<8051.h> > __sfr __at (0xf1) f_wren; > __sfr __at (0xf2) f_pp; > __sfr __at (0xf3) f_wr_adrH; > __sfr __at (0xf4) f_wr_adrM; > __sfr __at (0xf5) f_wr_adrL; > __sfr __at (0xf6) f_wr_dataH; > __sfr __at (0xf7) f_wr_dataM1; > __sfr __at (0xf8) f_wr_dataM2; > __sfr __at (0xf9) f_wr_dataL; > __sfr __at (0xfa) f_rw; > __sfr __at (0xfb) f_work; > > void main(void) > { > f_wren=0x06; > f_pp=0x02; > f_wr_adrH=0x00; > f_wr_adrM=0x02; > f_wr_adrL=0x00; > f_wr_dataH=0x12; > f_wr_dataM1=0x34; > f_wr_dataM2=0x56; > f_wr_dataL=0x78; > f_rw=0x01; > f_work=0x01; > while(F1==0) > f_work=0x00; > } > Line 18,f_wren at 0xf1 should have been assiged the value 0x06.However > the result of simulation is wrong,the f_wren's value did not changed. > I check the newpp.asm which is generated according to the newpp.c.The > newpp.asm is correct. > In newpp.asm's corresponding position generated the statment: mov > _f_wren,#0x06. > Thus I guess the compile is fine, the assembler or the linker may make > some mistakes. > > So,that is question: > 1.what is the mistake exactly? > 2.I wrote another assebly files(pp.asm) and involved the > sdas8051.exe,hoping to generate a hex file to be compared with the > newpp.hex. > So I can find out the mistake by comparing the pp.hex with > newpp.hex. > The command of sdas8051 is sdas8051.exe -x pp.hex pp.asm,but it did > not work,nothing to be generated. > However,the command(sdas8051.exe -o pp.rel pp.asm) generated the > pp.rel > question:How can I use the assembler to generate the .hex file? > 2011/3/23 roelof 't Hooft <roel...@itholland.nl> >> >> Hi Donald, >> >> On Wed, 2011-03-23 at 14:13 +0800, duck donal wrote: >> > Hi,Krish >> > Thank you so much for answering my questions detailedly! >> >> Krish does a much better job in explaining then I do, I can >> learn form him :-) >> >> >> > I‘ve got it.Thus next time I'll check the <****.h> file to find out >> > the specific register name of machine in SDCC. >> >> Actually you should read the datasheet and user manual that >> belongs to your specific processor and then check the header >> file for the correct statements. I personally hate the upper >> case names used in the header files so I tend to rewrite a >> header file for my specific processor. >> >> >> > Now I really want to know what SDCC compile flow is.How a c code >> > become to be a assembly code,even the machine code? >> >> Why would that be interesting to know other than the fact that >> it just works or you want to write compiler/linker stuff ? >> Go ahead and read this : >> http://sdcc.sourceforge.net/doc/sdccman.html/node186.html >> >> I for one have no clue about the compiler/linker/assembler >> internals and I do not really care about that :-) >> Just happy that there are good people out there willing to spend >> time on writing it ! >> >> >> > What is the differences between SDCC and GCC? >> >> SDCC is typically targetted at the 8051 and PIC processors. There >> are a few other architectures for which it can generate code. But >> as far as I know it started out as being a compiler for the 8051. >> GCC is a compiler which normally generates code for i386 and the >> like. Due to the structure it can (only ?) be retargetted for other >> 32bit processors. I use it for my arm7 and cortex-m3 projects. >> >> roelof >> >> >> >> >> >> ------------------------------------------------------------------------------ >> Enable your software for Intel(R) Active Management Technology to meet the >> growing manageability and security demands of your customers. Businesses >> are taking advantage of Intel(R) vPro (TM) technology - will your software >> be a part of the solution? Download the Intel(R) Manageability Checker >> today! http://p.sf.net/sfu/intel-dev2devmar >> _______________________________________________ >> Sdcc-user mailing list >> Sdcc-user@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/sdcc-user > > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user