visual studio – Trying to understand what is incorrrect in the following assembly code


I am hoping someone can lead me on the right path with understanding initializing multiple objects from a single structure in x86-64 and also shed some light on what it is I’m not understanding.

Below is the example code that I am working with. when I end up assembling the code, I get errors for the items which already have data entered during the initialization of the item (person1, person2, person3 and person5. I am using Visual Stuido 2022 17.11.10. The errors that I am getting is saying for each of these are as follows: “Too many initial values for structure” and as well as “String or text literal too long”. I am new to x86-64 and have been really enjoying everything that I have been learning.

any assistance is much appreciated. Thank you for even reading.

.DATA

; Define the structure
Person STRUCT
name db 32 dup(?)    ; 32 bytes for name
age  db ?            ; 1 byte for age
height dd ?          ; 4 bytes for height
Person ENDS


; Create multiple instances of the structure
person1 Person <"Alice", 30, 160>
person2 Person <"Bob", 25, 175>
person3 Person <"Charlie", 35, 180>

; Allocate uninitialized space
person4 Person <>

person5 Person <"Diana", 28, 165>

.CODE
main PROC

lea RAX, person1
lea RBX, person2

; Example code that uses RDI and RBX
; ...

ret
main ENDP
END`

I have tried to align the data of each instance with align 16 or align 8 but the same issue persists. Maybe I am not using them the right way?

Leave a Reply

Your email address will not be published. Required fields are marked *