Search code examples
assemblyx86-64yasm

Loop through character of a string in Assembly


If I have a list of strings, how can I loop through each character of each string? say a list data

data     db "00000123", NULL, "00000213"

how do I go about accessing each member? I know the length of each string is a constant length of 9, and I understand for normal types it would be byte[data+rsi] where rsi is my counter, but what does this do when strings are in play?

; loop
  ; get character from string
  ; check if character is end
  ; if yes then jump end
  ; do stuff with char
; end

Solution

  • Data written contiguously in an assembly language file will be contiguous in memory, and as such data will point to '0' (0x30), data+7 will point to '3' (0x33), and each of the locations in between will point to their corresponding characters in turn.