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

Back to Subject List

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

Read: times


 
#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            01/01/70 00:00      
   Code indented            01/01/70 00:00      
      Assemblers often have different syntax            01/01/70 00:00      
         Assembler            01/01/70 00:00      
            Why not use Keil A51 ?            01/01/70 00:00      
               why assembler?            01/01/70 00:00      
                  Libraries?!?!?            01/01/70 00:00      
                     Libraries good, but not always best            01/01/70 00:00      
                        Ok back to Data and Bit            01/01/70 00:00      
                           Manual            01/01/70 00:00      
                           ok back            01/01/70 00:00      
                              I C            01/01/70 00:00      
               Keil A51            01/01/70 00:00      
                  junk downloaders            01/01/70 00:00      
                  take a look at ASEM51            01/01/70 00:00      
                     asem-51 macros            01/01/70 00:00      
                        You don't have to use 'em            01/01/70 00:00      
                  re-think about tools            01/01/70 00:00      
                     ADuC842            01/01/70 00:00      
                        learn            01/01/70 00:00      
                           There are PLENTY of debuggers ...            01/01/70 00:00      
                              Documentation            01/01/70 00:00      
                                 interrupt vectors            01/01/70 00:00      
                                 Memo to Reinhard Keil            01/01/70 00:00      
                                 Keil docs are not bad.            01/01/70 00:00      
                                 Well ... Last time I had questions about ASEM51 ...            01/01/70 00:00      
                                    the good and the bad            01/01/70 00:00      
                                       Well, I must have mistyped            01/01/70 00:00      
                                          asem/asm            01/01/70 00:00      
                                          linker support?            01/01/70 00:00      
                                             it's provided by ASEM-51, I suppose            01/01/70 00:00      
   Ok back to the task at hand            01/01/70 00:00      
      make it easy for yourself            01/01/70 00:00      
         I’m afraid the hard ware is non negotiable            01/01/70 00:00      
            well, ....            01/01/70 00:00      
               Dinosours, I2Cs, Gang-bang???            01/01/70 00:00      
                  1st            01/01/70 00:00      
                     Simple approach            01/01/70 00:00      
                        yes            01/01/70 00:00      
                           For Free :-)            01/01/70 00:00      

Back to Subject List