Advertisement
obernardovieira

Copy to 2 lines to 2 columns(with video memory) [Intel 8086]

Jun 16th, 2015
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .8086
  2. .model small
  3. .stack 2048
  4.  
  5. dseg    segment para public 'data'
  6.  
  7.     fromLine    db  9       ;from line we will copy
  8.     toColumn    db  35      ;to column we will copy
  9.     inLine      db  0       ;which line are we?
  10.  
  11. dseg    ends
  12.  
  13. cseg    segment para public 'code'
  14. assume  cs:cseg, ds:dseg
  15.  
  16. Main  proc
  17.     mov ax, dseg
  18.     mov ds, ax
  19.     mov ax,0b800h       ;B800 is the video memory adress
  20.     mov es,ax           ;move that adress to es
  21.                         ;es stands for "extra segment"
  22.  
  23.     mov bl, 00100000b   ;[0][010][0000]b -> binary (*see below)
  24.  
  25. newLine:
  26.     mov cx, 24          ;how much chars we will copy?
  27.                         ;24 is the maximum, because there are just 24 lines
  28.  
  29.     mov ax, 160         ;every line has 80 columns, but in video memory it has word size
  30.     mov bh, fromLine    ;so 80*2 = 160
  31.     add bh, inLine
  32.     mul bh
  33.     mov di, ax          ;calculate and put in di the index to start copy
  34.  
  35.  
  36.     mov ax, 2           ;every column is word sized
  37.     mov bh, toColumn    ;to comun 25 for exemplo, we need 35*2, same thing above
  38.     add bh, inLine
  39.     mul bh
  40.     mov si, ax          ;calculate and put in si the index to where we will copy
  41. ciclo:
  42.     mov bh, es:[di]     ;get the text from screen
  43.  
  44.     mov es:[si], bh     ;move the space to video adreess (in other words, write a space on screen)
  45.     mov es:[si+1], bl   ;change color
  46.  
  47.     add di, 2
  48.     add si, 160
  49.  
  50.     loop ciclo          ;repeat until cx = 0, In every loop, cx is decremented
  51.  
  52.     inc inLine
  53.     cmp inLine, 2       ;2 is the number os lines we will copy
  54.     jne newLine
  55.  
  56.     mov ah,4CH
  57.     int 21H
  58. main    endp
  59.  
  60. cseg    ends
  61. end     main
  62.  
  63. ;the first 0 means static, if 1, text will be blinking
  64. ;the next 3 digits is for brackground color [000-111]
  65. ;the next 4 digits is for text color [000-1111]
  66. ;colors
  67. ;black          0000
  68. ;blue           0001
  69. ;gren           0010
  70. ;cyan           0011
  71. ;red            0100
  72. ;magenta        0101
  73. ;brown          0110
  74. ;light grey     0111
  75. ;dark grey      1000
  76. ;light blue     1001
  77. ;light green    1010
  78. ;light cyan     1011
  79. ;light red      1100
  80. ;light magenta  1101
  81. ;yellow         1110
  82. ;white          1111
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement