Sunday, January 16, 2022

Write instructions to calculate sum of 2 arrays.

 Include irvine32.inc

;AddTwo.asm-adds two 32-bit integer.

;chapter3 example

.386

.model flat,stdcall

.stack 4096

ExitProcess proto,dwExitCode:dword

.data 

array1 dword 2,4,6,9,5

array2 dword 3,6,5,1,1

sum dword 5 dup(?)

.code

main proc

mov ebx,OFFSET sum

mov edi,OFFSET array1

mov esi,OFFSET array2

mov ecx,LENGTHOF array1

L1:

mov eax,0

add eax,[edi]

add eax,[esi]

mov [ebx],eax


call writeHex

call crlf

add edi,TYPE array1

add esi,TYPE array2

add ebx,4

loop L1

call dumpregs

  invoke ExitProcess,0

  main endp

  end main

No comments:

Post a Comment