Enthernet Code
DIIDevHeads IoT Integration Server
•Created by Marvee Amasi on 9/11/2024 in #firmware-and-baremetal
Error in Calculating Section Size with .set Directive in x86_64 Assembly
@Marvee Amasi The error you encountered when assembling your code (
Error: invalid operands (.data and *UND* sections) for '-' when setting 'hex_size'
) suggests that the .set
directive is incorrectly used, involving symbols from incompatible sections.
To correctly calculate the size of a data section ( string), ensure that the labels used for size calculation are within the same section.
- Place a start label before your data (e.g., hex_str_start
) and an end label after it (e.g., hex_str_end
).
- Use these labels to calculate the size: .set hex_size, hex_str_end - hex_str_start
.
This approach ensures that both labels are defined within the same section ( .data
), allowing for valid arithmetic operations. This should resolve the assembler error related to operand incompatibility.5 replies