??? 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). |