Advertisement
obernardovieira

Write a vector in screen (diagonal) [Intel 8086]

Jun 15th, 2015
517
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.     diagonal1   db  24 dup('*')
  8.     diagonal2   db  24 dup('*')
  9.  
  10. dseg    ends
  11.  
  12. cseg    segment para public 'code'
  13. assume  cs:cseg, ds:dseg
  14.  
  15. Main  proc
  16.     mov ax, dseg
  17.     mov ds, ax
  18.     mov ax,0b800h       ;B800 is the video memory adress
  19.     mov es,ax           ;move that adress to es ;es stands for "extra segment"
  20.  
  21.     ;diagonal from left to righ
  22.     mov bl, 00100000b   ;green background
  23.     xor si, si          ;leftmost in screen
  24.     xor di, di
  25.     mov cx, 24          ;number o lines
  26. ciclo:
  27.     mov bh, diagonal1[di]
  28.     mov es:[si], bh     ;copy char in vector
  29.     mov es:[si+1], bl   ;set background green
  30.     inc di
  31.                         ;you know, every line has 80 columns, but in video memory
  32.                         ;it's 160.
  33.     add si, 162         ;add one line and one column
  34.     loop ciclo
  35.  
  36.  
  37.     ;diagonal from right to left
  38.     mov bl, 01000000b   ;red background
  39.     mov si, 158         ;leftmost in screen
  40.     xor di, di          ;rightmost in screen
  41.     mov cx, 24          ;number o lines
  42. ciclo2:
  43.     mov bh, diagonal2[di]
  44.     mov es:[si], bh     ;copy char in vector
  45.     mov es:[si+1], bl   ;set background red
  46.     inc di
  47.                         ;you know, every line has 80 columns, but in video memory
  48.                         ;it's 160.
  49.     add si, 158         ;add one line and subtract one column
  50.     loop ciclo2
  51.  
  52.  
  53.  
  54.  
  55.     mov ah,4CH
  56.     int 21H
  57. main    endp
  58.  
  59. cseg    ends
  60. end     main
  61.  
  62. ;the first 0 means static, if 1, text will be blinking
  63. ;the next 3 digits is for brackground color [000-111]
  64. ;the next 4 digits is for text color [000-1111]
  65. ;colors
  66. ;black          0000
  67. ;blue           0001
  68. ;gren           0010
  69. ;cyan           0011
  70. ;red            0100
  71. ;magenta        0101
  72. ;brown          0110
  73. ;light grey     0111
  74. ;dark grey      1000
  75. ;light blue     1001
  76. ;light green    1010
  77. ;light cyan     1011
  78. ;light red      1100
  79. ;light magenta  1101
  80. ;yellow         1110
  81. ;white          1111
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement