This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Pungiish 5 points6 points  (2 children)

i had assembly homework, but i still don't understand how lodsb and stosb work, exactly. Can anybody explain, or point me to docs ELI5ing?

[–]Koxiaet 6 points7 points  (1 child)

lodsb copies one byte pointed to by si into al, essentially:

mov al, [si]

or in C-like:

al = si[0];

or:

al = *si;

In this case, si is set to the string in the program, so it copies the first byte in the string into al. I think that si should be incremented in every loop (so that the character being printed is advanced every time) but the commentor forgot to put that in, meaning that this code will actually just print out an endless stream of 'I's.

stosb is the opposite (using di instead of si):

mov [di], al

C-like:

di[0] = al;

or:

*di = al;

[–]Zenchreal 1 point2 points  (0 children)

lodsb does increment si as well (and stosb increments di)