MichaelPetch

crtc1

Dec 19th, 2020 (edited)
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. .model small
  2. .stack 256
  3.  
  4. PAGE_NUM equ 3
  5. PAGE_ROWS equ 25
  6. PAGE_COLS equ 80
  7.  
  8. PAGE_SIZE equ (PAGE_ROWS * PAGE_COLS + 1023) AND (-1024)
  9. PAGE_OFFSET equ PAGE_NUM * PAGE_SIZE
  10.  
  11. VIDMEM_SEG equ 0b800h + (PAGE_OFFSET * 2) / 16
  12. VIDMEM_ADDR equ 0b8000h + (PAGE_OFFSET * 2)
  13.  
  14. CRTC_ADDR_REG equ 03d4h
  15. CRTC_DATA_REG equ CRTC_ADDR_REG + 1
  16. CRTC_START_ADDR_MSB equ 0ch
  17. CRTC_START_ADDR_LSB equ 0dh
  18.  
  19. WHITE_ON_MAGENTA equ 057h
  20.  
  21. .code
  22. start:
  23. ; Update the MSB (Most significant byte of the Start address)
  24. mov dx, CRTC_ADDR_REG
  25. mov al, CRTC_START_ADDR_MSB
  26. out dx, al
  27.  
  28. mov dx, CRTC_DATA_REG
  29. mov al, PAGE_OFFSET SHR 8
  30. out dx, al
  31.  
  32. ; Update the LSB (Least significant byte of the Start address)
  33. mov dx, CRTC_ADDR_REG
  34. mov al, CRTC_START_ADDR_LSB
  35. out dx, al
  36.  
  37. mov dx, CRTC_DATA_REG
  38. mov al, PAGE_OFFSET AND 0ffh
  39. out dx, al
  40.  
  41. ; At this point the start address has been changed to the specified
  42. ; page. This should work for CGA/EGA/VGA text modes. We can now write
  43. ; to that page directly in memory and the characters we write should
  44. ; appear on the display.
  45.  
  46. ; In this example the page number was set to 3. For 80x25 text mode
  47. ; so VIDMEM_SEG will be 0b800+300h=0BB00h . Page 0 would be 0b800,
  48. ; Page 1 would be 0b900h, Page 2 would be 0ba00 etc.
  49.  
  50. mov ax, VIDMEM_SEG
  51. mov es, ax
  52. mov word ptr [es:0000h], (WHITE_ON_MAGENTA SHL 8) OR 'M'
  53. mov word ptr [es:0002h], (WHITE_ON_MAGENTA SHL 8) OR 'D'
  54. mov word ptr [es:0004h], (WHITE_ON_MAGENTA SHL 8) OR 'P'
  55.  
  56. mov ax, 04c00h
  57. int 21h
  58.  
  59. end start
Add Comment
Please, Sign In to add comment