Advertisement
Ae_Mc

NASM Rectangle

Dec 23rd, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 256
  2.  
  3. mov ax, 0x0013
  4. int 0x10
  5. push 15
  6. push 20
  7. push 50
  8. push 150
  9. push 149
  10. call rectangle
  11. add sp, 10
  12.  
  13. while:
  14.         mov ah, 0
  15.         int 0x16
  16.         cmp al, 'q'
  17. jnz while
  18.  
  19. mov ah, 0x00
  20. mov al, 0x03
  21. int 0x10
  22. ret
  23.  
  24. rectangle:
  25.         push bp
  26.         mov bp, sp
  27.         push bx
  28.         push ds
  29.         push si
  30.         push ax
  31.         push cx
  32.         mov bx, 0xA000 ; Сегмент с видеопамятью
  33.         mov ds, bx
  34.         mov ax, [bp + 8] ; y1
  35.         mov bx, 320
  36.         mul bx
  37.         mov bx, ax ; in bx — zeroth byte of line y1
  38.         mov cl, [bp + 12] ; color
  39.         mov ax, [bp + 4]  ; y2
  40.         mov si, 320
  41.         mul si
  42.         mov si, ax
  43.         sub si, bx ; si — offset between top and bottom lines
  44.         mov ax, bx
  45.         add ax, [bp + 6]  ; add x2, in ax — x2 byte of line y1
  46.         add bx, [bp + 10] ; add x1, in bx — x1 byte of line y1
  47.         rect_while1:
  48.                 mov [bx], cl
  49.                 mov [bx + si], cl
  50.                 inc bx
  51.                 cmp bx, ax
  52.         jnz rect_while1
  53.         mov ax, [bp + 8] ; y1
  54.         mov bx, 320
  55.         mul bx
  56.         mov bx, ax
  57.         add bx, [bp + 10] ; add x1, in bx — x1 byte of line y1
  58.         mov si, 320
  59.         mov ax, [bp + 4]  ; y2
  60.         mul si
  61.         add si, [bp + 6]  ; x2
  62.         sub si, [bp + 10] ; sub x1, now si — offset between left and right lines
  63.         add ax, [bp + 10] ; add x1
  64.         rect_while2:
  65.                 mov [bx], cl
  66.                 mov [bx + si], cl
  67.                 add bx, 320
  68.                 cmp bx, ax
  69.         jnz rect_while2
  70.         pop cx
  71.         pop ax
  72.         pop si
  73.         pop ds
  74.         pop bx
  75.         pop bp
  76. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement