start.S 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
  2. │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
  3. ╞══════════════════════════════════════════════════════════════════════════════╡
  4. │ Copyright 2020 Justine Alexandra Roberts Tunney │
  5. │ │
  6. │ Permission to use, copy, modify, and/or distribute this software for │
  7. │ any purpose with or without fee is hereby granted, provided that the │
  8. │ above copyright notice and this permission notice appear in all copies. │
  9. │ │
  10. │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
  11. │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
  12. │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
  13. │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
  14. │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
  15. │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
  16. │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
  17. │ PERFORMANCE OF THIS SOFTWARE. │
  18. ╚─────────────────────────────────────────────────────────────────────────────*/
  19. .section .start,"ax",@progbits
  20. .globl _start
  21. .code16
  22. _start: jmp 1f # some bios scan for short jump
  23. 1: ljmp $0x600>>4,$_begin # end of bios data roundup page
  24. _begin: push %cs # memory model cs=ds=es = 0x600
  25. push %cs
  26. push %cs
  27. pop %ds
  28. pop %es
  29. pop %ss
  30. mov $0x70000>>4,%sp
  31. cld
  32. xor %ax,%ax
  33. xor %di,%di
  34. mov $0x7c00-0x600,%cx
  35. rep stosb # clears our bss memory
  36. xchg %di,%bx # start buffer at 07c00
  37. inc %cx # start at first sector
  38. xor %dh,%dh # drive dl head zero
  39. mov $0x0200+v_sectors,%ax # read sectors
  40. int $0x13 # disk service
  41. // 𝑠𝑙𝑖𝑑𝑒
  42. .section .yoink
  43. nopw main