proc-exercise_soln

proc-exercise_soln - Pass addresses of array, size, and sum...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Exercise 1 — addresses via registers Write a procedure to add all elements in an array. Pass addresses of array, size, and sum through registers. Show the calling program. Let VECTOR be the array, VSIZE hold the size, and VSUM hold the sum. All these variables are word variables. Let BX hold the address of VECTOR, CX hold the value of VSIZE, and DI hold the address of VSUM. ADDARRAY PROC FAR PUSH AX PUSH BX PUSH CX MOV AX, 0 NEXT: ADD AX, [BX] ADD BX, 2 LOOP NEXT MOV [DI], AX POP CX POP BX POP AX RET ADDARRAY ENDP Calling program LEA BX, VECTOR MOV CX, VSIZE LEA DI, VSUM CALL ADDARRAY
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Exercise 2 — addresses via table Write a procedure to add all elements in an array.
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Pass addresses of array, size, and sum through a table in memory. Show the calling program. Let VECTOR be the array, VSIZE hold the size, and VSUM hold the sum. All these variables are word variables. Let TABLE hold the address of VECTOR, TABLE+2 hold the address of VSIZE, and TABLE+4 hold the address of VSUM. ADDARRAY PROC FAR PUSH AX PUSH BX PUSH CX PUSH DI MOV BX, TABLE MOV DI, TABLE+2 MOV CX, [DI] MOV DI, TABLE+4 MOV AX, 0 NEXT: ADD AX, [BX] ADD BX, 2 LOOP NEXT MOV [DI], AX POP DI POP CX POP BX POP AX RET ADDARRAY ENDP Calling program LEA BX, VECTOR MOV TABLE, BX LEA BX, VSIZE MOV TABLE+2, BX LEA BX, VSUM MOV TABLE+4, BX CALL ADDARRAY...
View Full Document

This note was uploaded on 01/25/2012 for the course EE 3750 taught by Professor Desouza during the Fall '08 term at LSU.

Page1 / 2

proc-exercise_soln - Pass addresses of array, size, and sum...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online