Source.asm

mail@pastecode.io avatar
unknown
assembly_x86
7 months ago
781 B
2
Indexable
Never
TITLE HW3_111502563
INCLUDE Irvine32.inc

CountMatches PROTO,
    pArray1: PTR SDWORD,
    pArray2: PTR SDWORD,
    arraySize: DWORD

.data
array1 SDWORD 10, 5, 4, -6, 2, 11, 12
array2 SDWORD 10, 5, 3, 1, 4, 2, -6

.code
main PROC
    invoke CountMatches, OFFSET array1, OFFSET array2, LENGTHOF array1
    mov edx, eax
    call WriteString
    call Crlf

    exit
main ENDP

CountMatches PROC USES ecx esi edi edx,
    pArray1: PTR SDWORD,
    pArray2: PTR SDWORD,
    arraySize: DWORD

    mov eax, 0
    mov ecx, arraySize
    mov esi, pArray1
    mov edi, pArray2
    
L1:
    mov ebx, [esi]
    mov edx, [edi]
    cmp ebx, edx
    jne L2
    inc eax
L2: 
    add esi, 4
    add edi, 4
    loop L1
    ret
CountMatches ENDP

END main
Leave a Comment