Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 256
- PAGE_NUM equ 3
- PAGE_ROWS equ 25
- PAGE_COLS equ 80
- PAGE_SIZE equ (PAGE_ROWS * PAGE_COLS + 1023) AND (-1024)
- PAGE_OFFSET equ PAGE_NUM * PAGE_SIZE
- VIDMEM_SEG equ 0b800h + (PAGE_OFFSET * 2) / 16
- VIDMEM_ADDR equ 0b8000h + (PAGE_OFFSET * 2)
- CRTC_ADDR_REG equ 03d4h
- CRTC_DATA_REG equ CRTC_ADDR_REG + 1
- CRTC_START_ADDR_MSB equ 0ch
- CRTC_START_ADDR_LSB equ 0dh
- WHITE_ON_MAGENTA equ 057h
- .code
- start:
- ; Update the MSB (Most significant byte of the Start address)
- mov dx, CRTC_ADDR_REG
- mov al, CRTC_START_ADDR_MSB
- out dx, al
- mov dx, CRTC_DATA_REG
- mov al, PAGE_OFFSET SHR 8
- out dx, al
- ; Update the LSB (Least significant byte of the Start address)
- mov dx, CRTC_ADDR_REG
- mov al, CRTC_START_ADDR_LSB
- out dx, al
- mov dx, CRTC_DATA_REG
- mov al, PAGE_OFFSET AND 0ffh
- out dx, al
- ; At this point the start address has been changed to the specified
- ; page. This should work for CGA/EGA/VGA text modes. We can now write
- ; to that page directly in memory and the characters we write should
- ; appear on the display.
- ; In this example the page number was set to 3. For 80x25 text mode
- ; so VIDMEM_SEG will be 0b800+300h=0BB00h . Page 0 would be 0b800,
- ; Page 1 would be 0b900h, Page 2 would be 0ba00 etc.
- mov ax, VIDMEM_SEG
- mov es, ax
- mov word ptr [es:0000h], (WHITE_ON_MAGENTA SHL 8) OR 'M'
- mov word ptr [es:0002h], (WHITE_ON_MAGENTA SHL 8) OR 'D'
- mov word ptr [es:0004h], (WHITE_ON_MAGENTA SHL 8) OR 'P'
- mov ax, 04c00h
- int 21h
- end start
Add Comment
Please, Sign In to add comment