Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                 .model      tiny
  2.  
  3.                 .code
  4.                 org             0100h
  5. main:
  6.                 ;   set display mode to text mode
  7.                 mov     ah, 0h
  8.                 mov     al, 3h
  9.                 int     10h
  10.  
  11.                 mov     ah, 6h
  12.                 mov     al, 0h
  13.                 mov     bh, 70h
  14.                 mov     cx, 0000h
  15.                 mov     dx, 184fh
  16.                 int     10h
  17.  
  18.                 ; set initial value for cursor position
  19.                 mov     dh, 0h  ;   row variable
  20.                 mov     dl, 0h  ; column variable
  21.                 mov     bh, 0h
  22.  
  23. printA: ; move cursor to desired position and print 'a'
  24.  
  25.                 ; move cursor
  26.                 mov     ah, 2h
  27.                 int     10h
  28.  
  29.                 ;   push current cursor position to stack
  30.                 push    dx
  31.  
  32.                 ; wait with 10000 microsecs
  33.                 mov     ah, 86h
  34.                 mov     cx, 0000h
  35.                 mov     dx, 2710h
  36.                 int     15h
  37.  
  38.                 ;   pop current cursor position from stack
  39.                 pop     dx
  40.  
  41.                 ; print 'a'
  42.                 mov     ah, 9h  ; set to write character mode
  43.                 mov   cx, 1     ; print 1 character
  44.                 mov     bl, 70h ; set attribute for character
  45.                 mov     al, 61h ; set desired character to 'a'
  46.                 int     10h
  47.                 jmp     shiftPos
  48.  
  49. shiftPos:   ; decide if now on odd-indexed row or even-indexed row
  50.                 test    dh, 1h
  51.                 jz      evenShift   ; if on even-indexed, jump to evenShift
  52.  
  53. oddShift:   ; shift cursor index when in odd-indexed row
  54.                 dec     dl  ; decrease cursor column index (move cursor to the left)
  55.                 cmp     dl, 0   ; check if cursor is still in screen
  56.                 js      newlineEven ; if cursor is not in screen, go to newline
  57.                 jmp     printA  ; else continue printing 'a'
  58.  
  59. evenShift: ; shift cursor index when in even-indexed row
  60.                 inc     dl  ; increase cursor column index (move cursor to the right)
  61.                 cmp     dl, 50h ; check if cursor is still in screen
  62.                 jge     newlineOdd ; if cursor is not in screen, go to newline
  63.                 jmp     printA ; else continue printing 'a'
  64.  
  65. newlineEven: ; go to new line with even-indexed
  66.                 inc     dl ; increase cursor column index (move cursor back to screen)
  67.                 inc     dh  ; increase row index
  68.                 jmp     printA ; go to print 'a'
  69.  
  70. newlineOdd: ; go to new line with odd-indexed
  71.                 cmp     dh, 18h ; check if row index exceed 24
  72.                 jge     exit    ; if true, terminate program
  73.                 dec     dl  ; decrease cursor column index (move cursor back to screen)
  74.                 inc     dh  ; increase row index
  75.                 jmp     printA ; go to print 'a'
  76.  
  77. exit:
  78.                 ;   clear screen
  79.                 mov     ah, 6h
  80.                 mov     al, 0h  ; clear whole screen
  81.                 mov     bh, 7h
  82.                 mov     cx, 0h
  83.                 mov     dx, 184fh
  84.                 int     10h
  85.  
  86.                 ret
  87.                 end     main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement