Initialise array of strings in assembly -


i want create data array holding 5 strings in initialised data section. each string has 4 characters. each string has initial data "abcd" first string, "efgh" second string , on. null \0 character not needed string. how can initialise array of strings in assembly language?

this can think of far:

string    db    "abcdefghijklmnopqrst" 

is there clean syntax or way?

i using nasm 64 bit code.

first: @ assembly code level there no notion of "array", bits , bytes setup interpreted you, developer.

the straight forward way achieve array example break strings own block:

string1: db "abcd" string2: db "efgh" string3: db "ijkl" string4: db "mnop" string5: db "qrst" 

you've created individual string blocks can referenced unit individually. final step declare "array" through new data element contains starting address of each of 5 strings:

string_array: dq string1, string2, string3, string4, string5 

the above holds 5 addresses (each occupying 64 bits).

one gets address of array register somewhere in code segment. following rather brutal way go traversing array , getting each string itself:

xor rdx, rdx            ; starting @ offset 0 lea rdi, [string_array] ; rdi has address of array  mov rsi, [rdi+rdx]      ; address of string1  ; process string1 ; next string  add rdx, 8              ; next offset 64 bits mov rsi, [rdi+rdx]      ; address of string2  ; process string2 ; etc. 

without knowing doing array code approach may vary.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -