From: Jan Panteltje on 11 Jan 2010 08:06 On a sunny day (Sun, 10 Jan 2010 18:28:49 -0800) it happened John Larkin <jjlarkin(a)highNOTlandTHIStechnologyPART.com> wrote in <633lk5p9b1ti3lt94r1o8tek00vi8qcbsu(a)4ax.com>: >On Sun, 10 Jan 2010 19:16:49 -0600, "Tim Williams" ><tmoranwms(a)charter.net> wrote: > >>Heh, when writing assembly in BASIC (QB specifically), I often assign >>everything to an array then execute it. e.g., >> >>DIM Code(10) 'AS INTEGER implied by DEFINT A-Z >>Code(0) = &H1234 >>... >>Code(10) = &HF00F >> >>DEF SEG = VARSEG(Code(0)) >>CALL ABSOLUTE(VARPTR(Code(0)), stuff) >>DEF SEG >> >>That looks ugly after more than a few lines, so most of the time I read from >>a file as a first-run initialization. Also lots easier to maintain. Fine >>for simple routines that don't need to change. >> >>I don't really like DATA, it's the idea of having something and no way to >>access it. I suppose assigning entries of an array is the closest thing to >>predefined data (as in C or ASM), but I'm willing to bet it still executes >>an awful lot of lines to do it. Stupid QB... >> >>Tim > >PowerBasic (the DOS and Console Compiler versions) have inline >assembly, and it's easy to make links between the BASIC and assembly. >For exaample, you can name or dim a variable in Basic and just refer >to it in assembly. > >John But does PowerBasic run on a 8051 or 8052? Or is it even native in a 8052 ROM?
From: MooseFET on 11 Jan 2010 09:44 On Jan 10, 4:06 pm, Jan Panteltje <pNaonStpealm...(a)yahoo.com> wrote: > Released under GPL2: An 8051-8052 2 pass assembler for the Linux OS. > http://panteltje.com/panteltje/newsflex/a52-2.0.tgz > > This is a very simple assembler, and has less features then all the big macro ones. > But it has one feature all other ones do not have as far as I know: > It can generate binary output in MCS-52 BASIC data statements. > this makes writing inline asm easy in MCS-BASIC. > For example the code in q2.asm: > org $6000 > lcall mysub > ret > mysub: > mov $20.0,c > ret > when assembled like this: > a52 q2.asm -l -b1000 > > generates these BASIC lines: > 1000 rem code from q2 > 1002 data 18,96,4 > 1004 data 34 > 1006 data 146,0 > 1008 data 34 > 1010 org=24576 > 1012 for i=0 to 6 > 1014 read a:xby(org+i)=a:next > 1016 return > > You can then and do a > gosub 1000 > in MCS-BASIC to call the asm. > > Have fun. I think I will ask again at work if I can publish my 8052 sim program. What format does your program make its output in? Basic run down of what my Sim52 does: You describe the hardware complete with perhaps more than one 8052. It "event by event" simulates the hardware including the 8052s Very advanced break point system with 16 break points Examine registers etc Assemble new code Disassemble existing code Symbols substitute for values.
From: Jan Panteltje on 11 Jan 2010 10:32 On a sunny day (Mon, 11 Jan 2010 06:44:29 -0800 (PST)) it happened MooseFET <kensmith(a)rahul.net> wrote in <847912a2-a8e2-4f50-b1f0-2ddcd6a91a61(a)s31g2000yqs.googlegroups.com>: >On Jan 10, 4:06�pm, Jan Panteltje <pNaonStpealm...(a)yahoo.com> wrote: >> Released under GPL2: An 8051-8052 2 pass assembler for the Linux OS. >> �http://panteltje.com/panteltje/newsflex/a52-2.0.tgz >> >> This is a very simple assembler, and has less features then all the big m= >acro ones. >> But it has one feature all other ones do not have as far as I know: >> It can generate binary output in MCS-52 BASIC data statements. >> this makes writing inline asm easy in MCS-BASIC. >> For example the code in q2.asm: >> � � org $6000 >> � � lcall mysub >> � � ret >> mysub: >> � � mov $20.0,c >> � � ret >> when assembled like this: >> �a52 q2.asm -l -b1000 >> >> generates these BASIC lines: >> 1000 rem code from q2 >> 1002 data 18,96,4 >> 1004 data 34 >> 1006 data 146,0 >> 1008 data 34 >> 1010 � � � �org=24576 >> 1012 � � � �for i=0 to 6 >> 1014 � � � �read a:xby(org+i)=a:next >> 1016 � � � �return >> >> You can then and do a >> gosub 1000 >> in MCS-BASIC to call the asm. >> >> Have fun. > >I think I will ask again at work if I can publish my 8052 sim program. That would be nice, as I tried the ucsim that comes with sdcc: ~/compile/sdcc/sdcc/sim/ucsim it lives under the name 's51', and I have been unable to make it do *anything*, as all I get is 'cannot open file', although the files exist. The README seems to be the only documentation and this is the contents of the README: grml: ~/compile/sdcc/sdcc/sim # cat README sdcc/simulator -------------- I have no idea :) -- Michael >What format does your program make its output in? Intel Hex format, the BASIC program, and a list file. >Basic run down of what my Sim52 does: > >You describe the hardware complete with perhaps more than one 8052. >It "event by event" simulates the hardware including the 8052s >Very advanced break point system with 16 break points >Examine registers etc >Assemble new code >Disassemble existing code >Symbols substitute for values. Nice :-)
From: MooseFET on 11 Jan 2010 21:36 On Jan 11, 7:32 am, Jan Panteltje <pNaonStpealm...(a)yahoo.com> wrote: > On a sunny day (Mon, 11 Jan 2010 06:44:29 -0800 (PST)) it happened MooseFET > <kensm...(a)rahul.net> wrote in > <847912a2-a8e2-4f50-b1f0-2ddcd6a91...(a)s31g2000yqs.googlegroups.com>: > > > > >On Jan 10, 4:06 pm, Jan Panteltje <pNaonStpealm...(a)yahoo.com> wrote: > >> Released under GPL2: An 8051-8052 2 pass assembler for the Linux OS. > >> http://panteltje.com/panteltje/newsflex/a52-2.0.tgz > > >> This is a very simple assembler, and has less features then all the big m= > >acro ones. > >> But it has one feature all other ones do not have as far as I know: > >> It can generate binary output in MCS-52 BASIC data statements. > >> this makes writing inline asm easy in MCS-BASIC. > >> For example the code in q2.asm: > >> org $6000 > >> lcall mysub > >> ret > >> mysub: > >> mov $20.0,c > >> ret > >> when assembled like this: > >> a52 q2.asm -l -b1000 > > >> generates these BASIC lines: > >> 1000 rem code from q2 > >> 1002 data 18,96,4 > >> 1004 data 34 > >> 1006 data 146,0 > >> 1008 data 34 > >> 1010 org=24576 > >> 1012 for i=0 to 6 > >> 1014 read a:xby(org+i)=a:next > >> 1016 return > > >> You can then and do a > >> gosub 1000 > >> in MCS-BASIC to call the asm. > > >> Have fun. > > >I think I will ask again at work if I can publish my 8052 sim program. > > That would be nice, as I tried the ucsim that comes with sdcc: > ~/compile/sdcc/sdcc/sim/ucsim > it lives under the name 's51', and I have been unable to make it do *anything*, > as all I get is 'cannot open file', although the files exist. > The README seems to be the only documentation and this is the contents of the README: > grml: ~/compile/sdcc/sdcc/sim # cat README > sdcc/simulator > -------------- > > I have no idea :) > > -- Michael > > >What format does your program make its output in? > > Intel Hex format, the BASIC program, and a list file. > > >Basic run down of what my Sim52 does: > > >You describe the hardware complete with perhaps more than one 8052. > >It "event by event" simulates the hardware including the 8052s > >Very advanced break point system with 16 break points > >Examine registers etc > >Assemble new code > >Disassemble existing code > >Symbols substitute for values. > > Nice :-) I raised the question. The Boss is thinking about it. Technically they only own part of it. I did some work on the clock but most was off the clock. We will see if anything comes of it. I have also been thinking of making a few other projects for the 8052 public. (1) The Intel 8051 assembler had a preprocessor ability. I have thought it would be nice to be able to take that sort of source code in and make a reformatted output that worked on a GPLed assembler. (2) Most C for the 8051 really sucks. This is because the convert each source file to an object file and then link. This loses some information that could be used to great advantage on the 8051 processor. 2-A The type of jump and call used can be adapted based on where the code ends up in memory. 2-B They do a fairly poor job of economizing on stack use. While not doing extra Xdata transfers. 2-C Many of them store things MS then LS and end up doing a whole bunch of extra instructions because the 8051 doesn't have a DEC DPTR With LS-MS you can do this: MOVX A,@DPTR ; Add 1234 to FOO ADD A,#34H MOVX @DPTR,A INC DPTR MOVX A,@DPTR ADDC A,#12H MOVX @DPTR,A
From: Jan Panteltje on 12 Jan 2010 07:58
On a sunny day (Mon, 11 Jan 2010 18:36:20 -0800 (PST)) it happened MooseFET <kensmith(a)rahul.net> wrote in <14989ea6-1e2c-4ee8-88b0-da4448acfc71(a)s31g2000yqs.googlegroups.com>: >On Jan 11, 7:32�am, Jan Panteltje <pNaonStpealm...(a)yahoo.com> wrote: >> On a sunny day (Mon, 11 Jan 2010 06:44:29 -0800 (PST)) it happened MooseF= >ET >> <kensm...(a)rahul.net> wrote in >> <847912a2-a8e2-4f50-b1f0-2ddcd6a91...(a)s31g2000yqs.googlegroups.com>: >> >> >> >> >On Jan 10, 4:06�pm, Jan Panteltje <pNaonStpealm...(a)yahoo.com> wrote: >> >> Released under GPL2: An 8051-8052 2 pass assembler for the Linux OS. >> >> �http://panteltje.com/panteltje/newsflex/a52-2.0.tgz >> >> >> This is a very simple assembler, and has less features then all the bi= >g m= >> >acro ones. >> >> But it has one feature all other ones do not have as far as I know: >> >> It can generate binary output in MCS-52 BASIC data statements. >> >> this makes writing inline asm easy in MCS-BASIC. >> >> For example the code in q2.asm: >> >> � � org $6000 >> >> � � lcall mysub >> >> � � ret >> >> mysub: >> >> � � mov $20.0,c >> >> � � ret >> >> when assembled like this: >> >> �a52 q2.asm -l -b1000 >> >> >> generates these BASIC lines: >> >> 1000 rem code from q2 >> >> 1002 data 18,96,4 >> >> 1004 data 34 >> >> 1006 data 146,0 >> >> 1008 data 34 >> >> 1010 � � � �org=24576 >> >> 1012 � � � �for i=0 to 6 >> >> 1014 � � � �read a:xby(org+i)=a:next >> >> 1016 � � � �return >> >> >> You can then and do a >> >> gosub 1000 >> >> in MCS-BASIC to call the asm. >> >> >> Have fun. >> >> >I think I will ask again at work if I can publish my 8052 sim program. >> >> That would be nice, as I tried the ucsim that comes with sdcc: >> �~/compile/sdcc/sdcc/sim/ucsim >> it lives under the name 's51', and I have been unable to make it do *anyt= >hing*, >> as all I get is 'cannot open file', although the files exist. >> The README seems to be the only documentation and this is the contents of= > the README: >> grml: ~/compile/sdcc/sdcc/sim # cat README >> sdcc/simulator >> -------------- >> >> I have no idea :) >> >> -- Michael >> >> >What format does your program make its output in? >> >> Intel Hex format, the BASIC program, and a list file. >> >> >Basic run down of what my Sim52 does: >> >> >You describe the hardware complete with perhaps more than one 8052. >> >It "event by event" simulates the hardware including the 8052s >> >Very advanced break point system with 16 break points >> >Examine registers etc >> >Assemble new code >> >Disassemble existing code >> >Symbols substitute for values. >> >> Nice :-) > >I raised the question. The Boss is thinking about it. >Technically they only own part of it. I did some work >on the clock but most was off the clock. We will see >if anything comes of it. Great. >I have also been thinking of making a few other projects >for the 8052 public. > >(1) >The Intel 8051 assembler had a preprocessor ability. I have >thought it would be nice to be able to take that sort of source >code in and make a reformatted output that worked on a GPLed >assembler. The 8051 assembler was very expensive, I had it on the job, 2500$ or so? So, I could not take that home, so I wrote my own in C, on my clone CP/M system that I also wrote myself in Z80 asm. :-) So that preprocessor would indeed be a possible project. >(2) >Most C for the 8051 really sucks. This is because the convert >each source file to an object file and then link. This loses >some information that could be used to great advantage on the >8051 processor. Tell me something, I am in the middle of it. I use sdcc (open source), it has a C compiler and an assembler. It can target 8051, Z80, PIC16, and also PIC18, but only some the latter I think. What I wanted to do is compile some universal routines that take a RAM address as input, and an other RAM address as output, at org <somewhere in RAM> that use all vars in RAM, so I can write real C, and start that main() from a BASIC call, and including floating point and math libs. I am halfway there, but the C looks weird full of stuff like volatile __xdata __at (0x7000) unsigned char ival1; So, why should it not be possible. But anyways that sdcc C compiler should work OK with the EPROM versions 8749? Not sure if I still have one. I still have an EPROM eraser bulb though :-) >2-A >The type of jump and call used can be adapted based on >where the code ends up in memory. > >2-B >They do a fairly poor job of economizing on stack use. While >not doing extra Xdata transfers. Have a look at 'sdcc', it is big. http://sdcc.sourceforge.net/ It has a *lot* of command line optimising options, just beginning to investigate them all. I prefer C, as MCS-BASIC sucks anyways with those line numbers..., and is slow. I was looking last night at the asm sdcc generates, and indeed your example below is an example of that :-) >2-C >Many of them store things MS then LS and end up doing a whole >bunch of extra instructions because the 8051 doesn't have a >DEC DPTR With LS-MS you can do this: > > MOVX A,@DPTR ; Add 1234 to FOO > ADD A,#34H > MOVX @DPTR,A > INC DPTR > MOVX A,@DPTR > ADDC A,#12H > MOVX @DPTR,A > I know, this is from the 8052AH BASIC FAQ: QUESTION I am writing in assembly language and I notice that the 8052AH has no decrement DPTR instruction. What is the easiest. shortest or simplest way to decrement the DPTR? ANSWER The shortest one we know is: XCH A, DPL ; SWAPA<>DPL JNZ DECDP ; DPH = DPH-1 IF DPL = O DEC DPH DECDP: DEC A ; DPL = DPL-1 XCH A, DPL This routine affects no flags or registers (except the DPTR) either! |