;;;;;;;;;;;;;;;;;
;; testsecond.asm - test simple second stage boot loader
;; 
;; v 0.01  Joseph Osako 3 June 2002

VBIOS   equ 0x10   ; BIOS interrupt vector for video services
ttype   equ 0x0E   ; insert character in AL as if screen were teletype
EOL   equ 0   ;end of string marker
CR   equ 0x0D
LF   equ 0x0A

%macro write 1
   mov si, %1
   call printstr
%endmacro

entry:
   mov ax, cs
   mov ds, ax
   write success
;  jmp $
  ; 'return' to the first stage via a faked call frame set up earlier
  retf

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Auxilliary functions

;; printstr - prints the string point to by SI
printstr:
   push ax
   mov ah, ttype     ; set function to 'teletype mode'
.loop:   
   lodsb   ; update byte to print
   cmp al, EOL   ; test that it isn't EOL
   jz .endstr
   int  VBIOS   ; put character in AL at next cursor position
   jmp short .loop
.endstr:
   pop ax
   ret

;;;;;;;;;;;;;;;;;;;;;;;;;
;; data
success   db 'Control successfully transferred to second stage.', CR, LF, EOL

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; pad out to 512

space   times 0x0200 - ($-$$) db 0