This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I am using an example in the assembly tools document SPRU513U on page 138, where in the struct there is a string as a member. The listing file generated by the example has a line of opcode that is confusing.
TMS320C2000 Assembler PC v18.12.3 Mon Feb 1 08:39:59 2021
Copyright (c) 1996-2018 Texas Instruments Incorporated
directive_struct4.asm PAGE 1
1 BIT_REC .struct ; stag
2 0000 STREAM .string 64
3 0040 BIT7 .field 7 ; bits1 = 64
4 0040 BIT9 .field 9 ; bits2 = 64
5 0041 BIT10 .field 10 ; bits3 = 65
6 0042 X_INT .int ; x_int = 67
7 0043 BIT_LEN .endstruct ; length = 68
8 BITS .tag BIT_REC
9 00000000 8100- ADD ACC, @BITS.BIT7 ; move into acc
10 00000001 3E00 AND ACC, #007Fh ; mask off garbage bits
00000002 007F
11 00000000 BITS .usect ".ebss", BIT_REC
In line 9, the opcode it generates is 8100 while I think it should be 8140 as BITS.BIT7 is at address 0040.
If I replace the .string element with any other types, BITS.BIT7 would be the right address.
Please shed some light on this. Thanks.
Jinhui Zhang said:In line 9, the opcode it generates is 8100 while I think it should be 8140
I understand why you think that is the case. But you are overlooking the presence of the relocation, and how it affects the listing.
Take a closer look at line 9 ...
Jinhui Zhang said:9 00000000 8100- ADD ACC, @BITS.BIT7 ; move into acc
Notice the - character right after the opcode 8100. That means this instruction has a relocation associated with it, and this relocation is relative to the .ebss section. For more details, please search the C28x assembly tools manual for the sub-chapter titled Field 3: Object Code.
To see more details about this relocation, use the object file display utility ofd2000.
% ofd2000 -v --obj_display=none,relocs directive_struct4.obj OBJECT FILE: directive_struct4.obj Relocation Table 1/1 for Section 2 (".text") <0> R_PARTLS6 - Symbol-Relative Relocation Offset: 0x00000000 Symbol: .ebss (10) Displacement: 0x0040 (null) (null)
Note the relocation stores the offset of 0x0040 words.
The object file display utility ofd2000 is documented in the C28x assembly tools manual.
Thanks and regards,
-George
thanks George. It's clear now. I knew it was my ignorance but just don't know where. Using -v makes displacement show up and it explains it. Thanks again.