Advertisement
green1ant

var7 working digits

Mar 15th, 2019
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         org 100h
  2.  
  3. Start:
  4.         mov     si, 0
  5.         mov     di, 0
  6.  
  7.  
  8.         ;fill res arr with arr1
  9. ;FillFirst:
  10. ;       movsx   bx, [arr1 + si]
  11.  ;      mov     [res + si], bl
  12.   ;
  13.    ;    inc     si
  14.     ;   cmp     si, 4
  15.      ;  jne     FillFirst
  16.  
  17.        ; xor     si, si
  18.  
  19.         ;fill res arr with arr2
  20. ;FillSecond:
  21. ;       movsx   bx, [arr2 + si + 1]
  22.  ;      mov     [res + si], bl;bl
  23.   ;
  24.    ;    inc     si
  25.     ;   cmp     si, 4
  26.      ;  jne     FillSecond
  27.  
  28.  
  29.         xor     ax, ax
  30.         mov     si, 0
  31.         mov     di, 0
  32. ReviewRes:
  33.         movsx   bx, [res + si]
  34.         mov     di, 0
  35.  
  36.         WatchFurther:
  37.                 movsx   cx, [res + di]
  38.  
  39.                 cmp     si, di
  40.                 je      Continue
  41.  
  42.                 cmp     bx, cx
  43.                 je      BreakInnerLoop
  44.  
  45.                 cmp     di, 8
  46.                 je      @F
  47.                 jmp     Continue
  48.  
  49.                 @@:
  50.                 inc     ax
  51.                 call    PrintDigit
  52.                 jmp     BreakInnerLoop
  53.  
  54.                 Continue:
  55.                 inc     di
  56.                 cmp     di, 8
  57.                 jbe     WatchFurther
  58.  
  59.         BreakInnerLoop:
  60.  
  61.         inc     si
  62.         cmp     si, 8
  63.         jbe     ReviewRes
  64.  
  65.  
  66. PrintRes:
  67.  
  68.         push ax
  69.         mov     ah, $09
  70.         mov     dx, line
  71.         int 21h
  72.         pop ax
  73.  
  74.         ;print ax
  75.         mov     bx, ax
  76.         add     bx, '0'
  77.  
  78.         mov     ah, $02
  79.         mov     dx, bx
  80.         int 21h
  81.  
  82.         mov     ah, $09
  83.         mov     dx, pak
  84.         int 21h
  85.         mov     ah, $08
  86.         int 21h
  87.  
  88.         ret
  89.  
  90. PrintDigit:
  91.        ;digit in bx
  92.         push ax
  93.         push bx
  94.         push dx
  95.  
  96.         add     bx, '0'
  97.         mov     ah, $02
  98.         mov     dx, bx
  99.         int 21h
  100.  
  101.         mov     ah, $09
  102.         mov     dx, nextLine
  103.         int 21h
  104.  
  105.         pop dx
  106.         pop bx
  107.         pop ax
  108.  
  109.         ret
  110.  
  111.  
  112.  
  113. pak  db 13, 10, 'Press any key to exit...$'
  114. arr1 db 1, 2, 3, 4
  115. arr2 db 1, 5, 1, 1
  116. nextLine   db ', $'
  117. line       db 13, 10, '$'
  118.  
  119. res  db 1, 2, 3, 4, 5, 4, 1, 1
  120. ;res  db 8 dup (?)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement