Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Stefan Kanev
01/05/12 08:14
Modified:
  01/05/12 08:18

Read: 458 times
Silistra
Bulgaria


 
#185318 - ok back
Responding to: ???'s previous message
Its very possible i'm wrong in my uderstanding of things, but will show:
(i looked at manual, You linked , and is similar to assembler i'm using)

- Assembler tryes to help You in data(variables) placement process.
So You can declare bytes as

MY16bitword DATA 030h
MY8bitcounterA DATA 032h

or

DSEG
MY16bitword DS 2
MY8bitcounterA DS 1

In second variant You cant be sure what is exactly address of variables, but this is aim of assembler . First variant doesnt need to switch between segments and gives to You knowledge of address(If You need it).

- There are bit ,data, idata, xdata and code segments. You should know what that means, or go back to manual. Assembler counts haw many space You want in these areas and gives error if You exceed limits.
Thats all in Your assembler, as i saw.

But...

Suppose You declare (or try) variable in IDATA segment - for example
absolute address 130 decimal.
Correct way is to write

MYidatacounter IDATA 130D

or


ISEG
MYidatacounterB DS 1 ;unknown address, allocated by assembler.

In Your code correct usage is


CSEG
mov r0,#MYidatacounterB
mov @r0,#5
...


If You make mistake


mov r0,MYidatacounterB
mov @r0,#5

or

mov MYidatacounterB,#5

assembler will report ZERO errors , but program will be wrong.

What i want to say is that segments and segment-alike declarations are
uncomplete (in functionality) in many of simple assemblers.

So declaring all these variables as

MY16bitword EQU 030h
MY8bitcounterA EQU 032h
MYidatacounterB EQU 130D

will be with same result as using segments and hidden segment directives, but gives to You full control (and responsibility).

------
Back to Your post.

I have been discouraged from using the R1-7 registers due to code compatibility

Going with assembler eliminates this hesitation. You should use r0..r7 registers and 0..3 banks.
One possible way is to not use banks, this gives some chance to convert easily 8051asm to other 8_bit_micro_asm.




my code is just a small part of a much larger project

If it is new project - i suggest You to change assembler. Your code should be writen as library file , data declarations should be "transferable" between modules/libraries trough directives as PUBLIC and EXTERN , EXTRN.

IF You make "patch" to some old project - You should go in dept in existing data declarations. You code file will be included in big source file with "include" directive.

If this is new project and somebody other will manage data placement ,
You should make good lines to ensure You get what You want.
Biggeest problem is bitfield , packed in byte memory.
If You want to handle single bit , there is no problem with 8051.
If You want 2..8 correlated bits in one byte (which You can handle as single bits and as bits in single byte) then You should instruct assembler to give error if addresses are not suitable.
For example:


BSEG
mybit0 ds 1
...
mybitx ds 1
myByteBits0_7 ds 8
AftermyByteBits0_7 equ myByteBits0_7+8

IF ((AftermyByteBits0_7) AND 07h)<>0 )
Here we have error ,boy, go and see declaration about "myByteBits0_7"
ENDIF



I'm not sure in construction above, but this willl give to You error if all eight bits myByteBits0_7 are not in one byte.

One possible solution is to not use single bit manipulation instructions, but this is a lost.
Sou You need to colaborate hardly with other source(files/writers).
















List of 40 messages in thread
TopicAuthorDate
Assembly coding micro-converters      Donagh Choghlan      01/04/12 09:43      
   Code indented      Donagh Choghlan      01/04/12 09:56      
      Assemblers often have different syntax      David Prentice      01/04/12 10:14      
         Assembler      Donagh Choghlan      01/04/12 10:29      
            Why not use Keil A51 ?      David Prentice      01/04/12 10:38      
               why assembler?      Stefan KAnev      01/04/12 11:05      
                  Libraries?!?!?      Donagh Choghlan      01/05/12 02:46      
                     Libraries good, but not always best      Per Westermark      01/05/12 03:21      
                        Ok back to Data and Bit      Donagh Choghlan      01/05/12 04:34      
                           Manual      Donagh Choghlan      01/05/12 05:02      
                           ok back      Stefan KAnev      01/05/12 08:14      
                              I C      Donagh Choghlan      01/05/12 08:34      
               Keil A51      Donagh Choghlan      01/05/12 02:41      
                  junk downloaders        Erik Malund      01/05/12 05:57      
                  take a look at ASEM51      Richard Erlacher      01/05/12 08:22      
                     asem-51 macros      Donagh Choghlan      01/06/12 08:43      
                        You don't have to use 'em      Richard Erlacher      01/06/12 21:17      
                  re-think about tools      Stefan KAnev      01/06/12 14:08      
                     ADuC842      Donagh Choghlan      01/09/12 08:47      
                        learn      Stefan KAnev      01/09/12 14:46      
                           There are PLENTY of debuggers ...      Richard Erlacher      01/09/12 20:28      
                              Documentation      Donagh Choghlan      01/10/12 05:30      
                                 interrupt vectors      Stefan KAnev      01/10/12 06:41      
                                 Memo to Reinhard Keil      Erik Malund      01/10/12 07:56      
                                 Keil docs are not bad.      David Prentice      01/10/12 08:00      
                                 Well ... Last time I had questions about ASEM51 ...      Richard Erlacher      01/10/12 21:36      
                                    the good and the bad      Erik Malund      01/11/12 05:50      
                                       Well, I must have mistyped      Richard Erlacher      01/11/12 13:29      
                                          asem/asm      Robert Revens      01/11/12 16:43      
                                          linker support?      Maarten Brock      01/12/12 00:18      
                                             it's provided by ASEM-51, I suppose      Richard Erlacher      01/12/12 22:22      
   Ok back to the task at hand      Donagh Choghlan      01/05/12 08:26      
      make it easy for yourself      Erik Malund      01/05/12 09:09      
         Iím afraid the hard ware is non negotiable      Donagh Choghlan      01/05/12 09:26      
            well, ....      Erik Malund      01/05/12 09:46      
               Dinosours, I2Cs, Gang-bang???      Donagh Choghlan      01/05/12 10:19      
                  1st      Stefan KAnev      01/05/12 11:15      
                     Simple approach      Donagh Choghlan      01/06/12 04:59      
                        yes      Stefan KAnev      01/06/12 13:05      
                           For Free :-)      Donagh Choghlan      01/09/12 09:05      

Back to Subject List