Skip to content

Instantly share code, notes, and snippets.

@Aeres-u99
Last active July 24, 2018 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aeres-u99/924890ca1a41aef645084d61a309f3eb to your computer and use it in GitHub Desktop.
Save Aeres-u99/924890ca1a41aef645084d61a309f3eb to your computer and use it in GitHub Desktop.
The booting code and printing code
;
;A boot sector that prints the welcome message using function
;
[org 0x7c00] ; Tells the assembler where this code will be loaded
mov bx, Welcome_msg ; bx as parameter to function
call str_out
mov bx, Goodbye_msg
call str_out
hlt
jmp $ - 1
%include "Str_Out.asm"
;data
Welcome_msg:
db 'Welcome to the Potato Land!!',0 ; <-- 0 for the ending of routine
Goodbye_msg:
db 'Matane!!',0
;padding and magic number
times 510-($-$$) db 0
dw 0xaa55
;
;Printing function
;
pusha ; push the content of register to save it properly!!
str_out: mov ah,0x0e ;Interrupt requires 0x0e
printing: mov al, [bx] ;load the start of string into bx
int 0x10 ;call Interrupt 0x10,which upon having 0x0e in ah prints the char
add bx, 0x01 ;increment bx for the next character
cmp al,0 ; see if its zero, if yes that means the string has ended
jg printing ; jump on greater to prinitng
popa ;restore the content of registers
mov bx,0x00
ret ;finishing the fun call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment