Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- start:
- xor si, si
- xor bx, bx
- loop_first:
- movsx ax, [arr1 + si]
- xor di, di
- loop_second_of_first:
- movsx dx, [arr2 + di]
- cmp ax, dx
- je BreakLoopInsideFirst
- inc di
- cmp di, 4
- je AddToResFromFirst
- jmp EndLoopInsideFirst
- AddToResFromFirst:
- push si
- mov si, bx
- mov [res + si], al
- pop si
- inc bx
- ;call PrintDigit
- EndLoopInsideFirst:
- cmp di, 4
- jne loop_second_of_first
- BreakLoopInsideFirst:
- inc si
- cmp si, 4
- jne loop_first
- ;---------------------------------
- xor si, si
- loop_second:
- movsx ax, [arr2 + si]
- xor di, di
- loop_first_of_second:
- movsx dx, [arr1 + di]
- cmp ax, dx
- je BreakLoopInsideSecond
- inc di
- cmp di, 4
- je AddToResFromSecond
- jmp EndLoopInsideSecond
- AddToResFromSecond:
- push si
- mov si, bx
- mov [res + si], al
- pop si
- inc bx
- ;call PrintDigit
- EndLoopInsideSecond:
- cmp di, 4
- jne loop_first_of_second
- BreakLoopInsideSecond:
- inc si
- cmp si, 4
- jne loop_second
- ;---------------------------------
- ;ensure that res stores correct data
- mov ah, $09
- mov dx, line
- int 21h
- xor si, si
- PrintResultArr:
- movsx ax, [res + si]
- call PrintDigit
- inc si
- cmp si, bx
- jne PrintResultArr
- ;---------------------------------
- mov ah, $09
- mov dx, crash
- int 21h
- ;delete duplicates
- xor si, si
- ;print first
- movsx ax, [res]
- call PrintDigit
- mov cx, 1
- mov si, 1
- xor di, di
- loop_first3:
- movsx ax, [res + si]
- xor di, di
- loop_second3:
- movsx dx, [res + di]
- cmp ax, dx
- je BreakLoop3
- inc di
- cmp di, si
- je JustPrint
- jmp EndLoop3
- JustPrint:
- inc cx
- push bx
- mov bx, ax
- call PrintDigit
- pop bx
- EndLoop3:
- cmp di, si
- jne loop_second3
- BreakLoop3:
- inc si
- cmp si, bx
- jne loop_first3
- ;---------------------------------
- PrintRes:
- push ax
- mov ah, $09
- mov dx, line
- int 21h
- pop ax
- ;print ax
- mov bx, cx
- add bx, '0'
- mov ah, $02
- mov dx, bx
- int 21h
- mov ah, $09
- mov dx, pak
- int 21h
- mov ah, $08
- int 21h
- ret
- PrintDigit:
- ;digit in bx
- push ax
- push bx
- push dx
- mov bx, ax
- add bx, '0'
- mov ah, $02
- mov dx, bx
- int 21h
- mov ah, $09
- mov dx, nextLine
- int 21h
- pop dx
- pop bx
- pop ax
- ret
- pak db 13, 10, 'Press any key to exit...$'
- crash db 13, 10, '-----------$'
- arr1 db 1, 2, 3, 1
- arr2 db 2, 2, 5, 6 ; 2, 4, 5, 7
- nextLine db ', $'
- line db 13, 10, '$'
- res db 8 dup (?)
- ans db 8 dup (?)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement