I have a putstring fun ction that works great from a guide but im trying not to look at it to much
![Smile :-)](./images/smilies/icon_smile.gif)
This makes sense to me as it stores all the registers on the stack, well exactly:
60 PUSHA 18 Push AX, CX, DX, BX, original SP, BP, SI, and
DI
Ok so heres the first part of mmy string function:
Code: Select all
contents db "Test ",0
mov ecx, axcontents;
call showstring;
showstring:
pusha;
mov al, byte [ecx]; al = first char
Now in the guys from the tutorial he has the same (much more code but heres the part I dont understand)
Code: Select all
showstring:
pusha;
mov al, byte [ecx]; al = first char
pop edi <-------I dont understand why pop edi? as I cant remember setting edi anywhere? (Only set the segments es, ds , sp etc when setting stack)
it then gets used
;first line it seems edi gets used as an index but I didnt think edi was assigned anywhere? (Im in protected mode btw so no ints)
Code: Select all
mov bl, byte [edi] ; get next character
cmp bl, 0 ; is it 0 (Null terminator)?
je .done ; yep-bail out
Just to finally say I dont understand why edi points to the string start ? as this is how I set up my stack , yet the guys code from the guide works
Code: Select all
mov ax, 0x10 ; set data segments to data selector (0x10)
mov ds, ax
mov ss, ax
mov es, ax
mov esp, 90000h ; stack begins from 90000h
2 final things, one regarding:
60 PUSHA 18 Push AX, CX, DX, BX, original SP, BP, SI, and
DI
what does it mean by ORIGINAL SP, BP, SI, and
DI
as in the most recent values I set sp bp etc to?
Also where can I find some nasm assembly tutorials using the same syntax thats on the brokenthorn site?(http://www.brokenthorn.com/Resources/OSDev8.html) and that also teach basic assembly but that doest use any shortcut code that relies on some form of os runtime
Thanks
![Smile :-)](./images/smilies/icon_smile.gif)