[SOLVED] how to traverse byte array in assembly using nasm as assembler?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to traverse byte array in assembly using nasm as assembler?
hello, I am trying to learn assembly using nasm as assembler. I did not found example related to string operation. I had following example code,
global asm_strlen
section .data
section .bss
section .text
asm_strlen:
push ebp ; remember base pointer
mov ebp, esp ; init current base pointer
mov eax,0
mov ecx, [ebp + 8] ; get pointer to string
check:
movsb edx,[ecx] ; first byte
cmp edx,0
je out
inc ecx
inc eax
jmp check
out:
pop ebp ; pop return address in ebp
ret
my problem is at highlighted line, I am not getting how to copy a byte into 4 byte reg. rather what is syntax of mov instruction to mov byte to WORD DWORD etc.
if possible please give some example, and alternative solution if known.
I can use byte, WORD, DWORD keywords to move 1 2 4 bytes.
after this I got stuck that how to move byte to a byte pointer, I mean, if I have two byte pointers how can I copy them, as u explained I can do that with esi and edi, can u give some code example how to do this ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.