Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- Start:
- ;---------------------------------
- xor ax, ax
- mov si, 0
- mov di, 0
- xor bx, bx
- loop_first:
- movsx ax, [arr1 + si]
- xor di, di
- loop_second:
- movsx dx, [arr2 + di]
- cmp ax, dx
- je BreakLoop
- inc di
- cmp di, 4
- je AddToRes
- jmp EndLoop
- AddToRes:
- push si
- mov si, bx
- mov [res + si], al
- pop si
- inc bx
- call PrintDigit
- EndLoop:
- cmp di, 4
- jne loop_second
- BreakLoop:
- inc si
- cmp si, 4
- jne loop_first
- ;---------------------------------
- xor ax, ax
- mov si, 0
- mov di, 0
- loop_first2:
- movsx ax, [arr2 + si]
- xor di, di
- loop_second2:
- movsx dx, [arr1 + di]
- cmp ax, dx
- je BreakLoop2
- inc di
- cmp di, 4
- je AddToRes2
- jmp EndLoop2
- AddToRes2:
- push si
- mov si, bx
- mov [res + si], al
- pop si
- inc bx
- call PrintDigit
- EndLoop2:
- cmp di, 4
- jne loop_second2
- BreakLoop2:
- inc si
- cmp si, 4
- jne loop_first2
- ;---------------------------------
- ;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 2, 8, 2, 9
- arr2 db 5, 2, 6, 5 ; 2, 4, 5, 7
- nextLine db ', $'
- line db 13, 10, '$'
- testit db 2, 4, 5, 7, 7
- res db 8 dup (?)
- ans db 8 dup (?)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement