a better write procedure (nasm)

Programming, for all ages and all languages.
Post Reply
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

a better write procedure (nasm)

Post 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.
Matías Beretta
User avatar
Red Shaya
Posts: 15
Joined: Wed Oct 03, 2007 4:21 pm
Contact:

Post by Red Shaya »

You might want to reconsider your label naming :-)
".a" and ".b" are not the most self explanatory label names.
The Bina OS - More of a challenge then an OS
The Eddie OS - OS for kids and for fun loving adults
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

reply

Post by matias_beretta »

yes i know lol, i don't know why i do it but it seems to be easier to me...
Matías Beretta
Post Reply