atm959

Woo

Jun 29th, 2019
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BITS 16
  2. ORG 7C00h
  3.  
  4. start:
  5.     cli
  6.    
  7.     mov ah, 02h
  8.     mov al, 1
  9.     mov ch, 0
  10.     mov dh, 0
  11.     mov cl, 2
  12.     mov bx, loadLocation
  13.     int 13h
  14.    
  15.     xor ax, ax
  16.     push ax
  17.     popf
  18.     mov ds, ax
  19.     lgdt [gdt_desc]
  20.     mov eax, cr0
  21.     or eax, 1
  22.     mov cr0, eax
  23.     jmp 08h:protectedModeBegin
  24.  
  25. BITS 32
  26.  
  27. protectedModeBegin:
  28.     mov ax, 10h
  29.     mov ds, ax
  30.     mov ss, ax
  31.     mov esp, 90000h
  32.  
  33.     mov [0B8000h], BYTE 'P'
  34.     mov [0B8001h], BYTE 1Bh
  35.    
  36.     jmp loadLocation   
  37.  
  38. gdt:
  39. gdt_null:
  40.     dq 0
  41. gdt_code:
  42.     dw 0FFFFh
  43.     dw 0
  44.     db 0
  45.     db 10011010b
  46.     db 11001111b
  47.     db 0
  48. gdt_data:
  49.     dw 0FFFFh
  50.     dw 0
  51.     db 0
  52.     db 10010010b
  53.     db 11001111b
  54.     db 0
  55. gdt_end:
  56.  
  57. gdt_desc:
  58.     dw gdt_end - gdt
  59.     dd gdt
  60.  
  61.     times 510-($-$$) db 0
  62.     dw 0AA55h
  63.    
  64. loadLocation:
  65.     mov [0B8002h], BYTE 'L'
  66.     mov [0B8003h], BYTE 1Bh
  67.  
  68.     mov si, text
  69.     mov ax, 01h
  70.     mov bx, 01h
  71.     call placeText
  72.     mov si, text
  73.     mov ax, 02h
  74.     mov bx, 02h
  75.     call placeText
  76.     mov si, text
  77.     mov ax, 03h
  78.     mov bx, 03h
  79.     call placeText
  80.     mov si, text
  81.     mov ax, 04h
  82.     mov bx, 04h
  83.     call placeText
  84.     mov si, text
  85.     mov ax, 05h
  86.     mov bx, 05h
  87.     call placeText
  88.     mov si, text
  89.     mov ax, 06h
  90.     mov bx, 06h
  91.     call placeText
  92.     mov si, text
  93.     mov ax, 07h
  94.     mov bx, 07h
  95.     call placeText
  96.     mov si, text
  97.     mov ax, 08h
  98.     mov bx, 08h
  99.     call placeText
  100.    
  101. .loop:
  102.     jmp .loop
  103.  
  104. text:
  105.     db "This is some test text.", 0FFh
  106.    
  107. xPos: db 0
  108. yPos: db 0
  109.  
  110. temp1: dw 0
  111. temp2: dw 0
  112.  
  113. ;esi - Pointer to text
  114. ;ax - X Pos.
  115. ;bx - Y Pos.
  116. placeText:
  117.     mov [temp1], ax
  118.     mov ax, bx
  119.     mov bx, 160
  120.     mul bx
  121.     mov [temp2], ax
  122.     mov ax, [temp1]
  123.     mov bx, 2
  124.     mul bx
  125.     mov bx, ax
  126.     mov ax, [temp2]
  127.     add eax, ebx
  128.    
  129.     mov ecx, 0B8000h
  130.     add ecx, eax
  131. .placeTextLoop:
  132.     lodsb
  133.     cmp al, 0FFh
  134.     je .donePlacingText
  135.     mov [ecx], BYTE al
  136.     add ecx, 1h
  137.     mov [ecx], BYTE 1Bh
  138.     add ecx, 1h
  139.     jmp .placeTextLoop
  140. .donePlacingText:
  141.     ret
Advertisement
Add Comment
Please, Sign In to add comment