Description: A simple Assembly Language 8086 Programming Example that shows two asterisks at upper right and upper left corner of the screen and after some time they start moving towards each other and when they meet, their colors change and then they start going back to their original position.
[org 0x0100]
   jmp main
clearScreen:
   push ax
   push di
   mov ax , 0xB800
   mov es , ax
   mov di , 0
   clearNext:
      mov word [es:di] , 0x0720
      add di , 2
      cmp di , 4000
      jne clearNext
   pop di
   pop ax
   ret
delay:
   push cx
   push dx
   mov dx , 0
   outerLoop:
      mov cx , 0xFFFF
      innerLoop:
         loop innerLoop
      inc dx 
      cmp dx , 0x0009
      jnz outerLoop
      pop dx
      pop cx
      ret
main:
   mov ax , 0xB800
   mov es , ax
   mov di , 158
   mov si , 3840
   mov ah , 0x0F
   mov al , '*'
   towards:
      call clearScreen
      mov [es:di] , ax
      mov [es:si] , ax
      call delay
      add di , 154
      sub si , 154
      cmp si , di
      jg towards
   mov ah , 0x0D          ;Changing
Color
   away:
      call clearScreen
      mov [es:di] , ax
      mov [es:si] , ax
      call delay
      sub di , 154
      add si , 154
      cmp di , 158
      jge away
   mov ax , 0x4c00
   int 0x21
 18:33
18:33

No comments
Post a Comment