Advertisement
obernardovieira

Copy line 2 to line 15 [Intel 8086]

Jun 15th, 2015
548
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.     line db 3;the line we will start copy
  7. dseg    ends
  8.  
  9. cseg    segment para public 'code'
  10. assume  cs:cseg, ds:dseg
  11.  
  12. Main  proc
  13.     mov ax, dseg
  14.     mov ds, ax
  15.     mov ax,0b800h       ;B800 is the video memory adress
  16.     mov es,ax           ;move that adress to es
  17.                         ;es stands for "extra segment"
  18.  
  19.     mov cx, 2*80        ;2*80 we will copy 2 lines. Both with 80 columns
  20.     xor bx, bx
  21.     mov ax, 160         ;every video adress has a size of a word
  22.                         ;so we need to jump 160 columns (theory)
  23.     mov bl, line        ;then we want to start in third line, so multiply by three
  24.     mul bl
  25.     mov di, ax
  26.     mov si, 15*160      ;this is to where we will copy the text. Line 15
  27.     mov bl, 00100000b   ;[0][010][0000]b -> binary (*see below)
  28. ciclo:
  29.     mov bh, es:[di]     ;get the text from screen
  30.  
  31.     mov es:[si], bh     ;move the space to video adreess (in other words, write a space on screen)
  32.     mov es:[si+1], bl   ;change color
  33.     add di, 2           ;every video adress have a size of word, so let's add 2
  34.     add si, 2
  35.     loop ciclo          ;repeat until cx = 0, In every loop, cx is decremented
  36.  
  37.  
  38.     mov ah,4CH
  39.     int 21H
  40. main    endp
  41.  
  42. cseg    ends
  43. end     main
  44.  
  45. ;the first 0 means static, if 1, text will be blinking
  46. ;the next 3 digits is for brackground color [000-111]
  47. ;the next 4 digits is for text color [000-1111]
  48. ;colors
  49. ;black          0000
  50. ;blue           0001
  51. ;gren           0010
  52. ;cyan           0011
  53. ;red            0100
  54. ;magenta        0101
  55. ;brown          0110
  56. ;light grey     0111
  57. ;dark grey      1000
  58. ;light blue     1001
  59. ;light green    1010
  60. ;light cyan     1011
  61. ;light red      1100
  62. ;light magenta  1101
  63. ;yellow         1110
  64. ;white          1111
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement