Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Code    Segment
  3.     assume CS:Code, DS:Data, SS:Stack
  4.  
  5. Start:
  6.     mov ax, Code
  7.     mov DS, AX
  8.    
  9.     ; Starting coordinate set
  10.     mov dl,100
  11.     mov dh,100
  12.     push dx
  13.  
  14.     mov ax, 13h
  15.     int 10h
  16.  
  17.     mov ax, 0a000h
  18.     mov es, ax
  19.  
  20.     mov cl,128
  21.  
  22. Draw:
  23.     pop dx
  24.     xor ah,ah
  25.     mov al,dh
  26.     push dx
  27.     mov bx,320
  28.     mul bx
  29.     pop dx
  30.     add al,dl
  31.     jnc Pixel
  32.     inc ah
  33.  
  34. Pixel:
  35.     push dx ; exact pixel coordinate
  36.     mov di,ax
  37.     inc cl
  38.     mov es:[di],cl
  39.  
  40. Waitfor:
  41.     xor ah,ah
  42.     int 16h
  43.  
  44.     cmp al,27
  45.     jz  Program_Vege
  46.  
  47.     ; Was the pressed key a movement one?
  48.     cmp ah,75
  49.     jz  Lefter
  50.     cmp ah,77
  51.     jz  Righter
  52.     cmp ah,72
  53.     jz  Upper
  54.     cmp ah,80
  55.     jz  Downer
  56.  
  57.     jmp Waitfor
  58.  
  59. ; we change the dl (x) of dh (y) corordinate according to the pressed key (inc and dec 1 and -1)
  60. Lefter:
  61.     pop dx
  62.     dec dl
  63.     cmp dl,1
  64.     jnc Keeper
  65.     inc dl
  66. Righter:
  67.     pop dx
  68.     inc dl
  69.     cmp dl,250
  70.     jc  Keeper
  71.     dec dl
  72. Upper:
  73.     pop dx
  74.     dec dh
  75.     cmp dh,1
  76.     jnc Keeper
  77.     inc dh
  78. Downer:
  79.     pop dx
  80.     inc dh
  81.     cmp dh,200
  82.     jc  Keeper
  83.     dec dh
  84. Keeper: ; and we save the new coordinate, yay!
  85.     push dx
  86.     jmp Draw
  87.  
  88. Program_Vege:
  89.     mov ax,03h
  90.     int 10h
  91.     pop dx
  92.     mov ax, 4c00h
  93.     int 21h
  94.  
  95. Code    Ends
  96.  
  97. Data    Segment
  98.  
  99. Data    Ends
  100.  
  101. Stack   Segment
  102.  
  103. Stack   Ends
  104.     End Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement