Share Pastebin
Guest
Public paste!

osasm

By: a guest | Aug 24th, 2009 | Syntax: ASM (NASM) | Size: 2.35 KB | Hits: 255 | Expires: Never
Copy text to clipboard
  1. [BITS 16]            ; 16 bit code generation
  2. [ORG 0x7C00]     ; ORGin location is 7C00
  3.  
  4. JMP short main   ; Jump past disk description section
  5. NOP              ; Pad out before disk description
  6.  
  7. ; ------------------------------------------------------------------
  8. ; Disk description table, to make it a valid floppy
  9. ; Note: some of these values are hard-coded in the source!
  10. ; Values are those used by IBM for 1.44 MB, 3.5" diskette
  11.  
  12. OEMLabel            db "BERL OS"    ; Disk label - 8 chars
  13. BytesPerSector      dw 512          ; Bytes per sector
  14. SectorsPerCluster   db 1            ; Sectors per cluster
  15. ReservedForBoot     dw 1            ; Reserved sectors for boot record
  16. NumberOfFats        db 2            ; Number of copies of the FAT
  17. RootDirEntries      dw 224          ; Number of entries in root dir
  18. LogicalSectors      dw 2880         ; Number of logical sectors
  19. MediumByte          db 0F0h         ; Medium descriptor byte
  20. SectorsPerFat       dw 9            ; Sectors per FAT
  21. SectorsPerTrack     dw 18           ; Sectors per track (36/cylinder)
  22. Sides               dw 2            ; Number of sides/heads
  23. HiddenSectors       dd 0            ; Number of hidden sectors
  24. LargeSectors        dd 0            ; Number of LBA sectors
  25. DriveNo             dw 0            ; Drive No: 0
  26. Signature           db 41           ; Drive signature: 41 for floppy
  27. VolumeID            dd 00000000h    ; Volume ID: any number
  28. VolumeLabel         db "BERL OS"    ; Volume Label: any 11 chars
  29. FileSystem          db "FAT12"      ; File system type: don't change!
  30.  
  31. ; End of the disk description table
  32. ; ------------------------------------------------------------------
  33.  
  34. main:
  35. MOV BH, 00h
  36. MOV BL, 07h
  37. MOV AL, 1
  38. MOV BH, 0
  39. MOV BL, 059
  40. MOV CX, osmsgend - os_msg           ; calculate message size.
  41. MOV DL, 30
  42. MOV DH, 0
  43. PUSH CS
  44. POP ES
  45. MOV BP, os_msg
  46. MOV AH, 13h
  47. INT 10h
  48. JMP wel
  49.  
  50. wel:
  51. MOV BH, 00h
  52. MOV BL, 07h
  53. MOV AL, 1
  54. MOV BH, 0
  55. MOV BL, 059
  56. MOV CX, welcome_end - welcome       ; calculate message size.
  57. MOV DL, 32
  58. MOV DH, 2
  59. PUSH CS
  60. POP ES
  61. MOV BP, welcome
  62. MOV AH, 13h
  63. INT 10h
  64. JMP osmsgend
  65.                          
  66. welcome DB "Welcome !"
  67. welcome_end:
  68.                          
  69. os_msg DB "BerlOS v0.0.1"
  70. osmsgend:
  71. JMP $
  72.  
  73. ; Boot things
  74. TIMES 510-($-$$) DB 0               ; Fill the rest of the sector with zeros
  75. DW 0xAA55                                   ; Boot signature