Page 1 of 1

a better write procedure (nasm)

Posted: Fri Dec 28, 2007 10:38 am
by matias_beretta
hello, thanks for reading my topic. Yesterday i was playing with my bootsector and i noticed that i had to use a label for each string i wanted to write, so i decide to do this:

Code: Select all

call writethis ;PUSH IP
db "Hello", 10, 13, 0
call writethis
db "Hello again", 0
jmp $

writethis:
   pop si ;POP IP
   call write
   push si ;PUSH IP
   ret

write:
   mov ah, 0eh
   .a:
      mov al, [si]
      inc si
      cmp al, 0
      je .b
      int 10h
      jmp .a
   .b:
      ret
I posted this info because i think it is very helpful.

Posted: Tue Jan 01, 2008 10:32 am
by Red Shaya
You might want to reconsider your label naming :-)
".a" and ".b" are not the most self explanatory label names.

reply

Posted: Tue Jan 01, 2008 3:51 pm
by matias_beretta
yes i know lol, i don't know why i do it but it seems to be easier to me...