Exercise 8        Name _________________ Points  _    /20
 

Give the Assembler to implement the following using both Array indexing and String operations.
 
Two Examples: Square all the 32 bit values in a 10 entry array using String Operations and Array indexing. 
.data
    src dword 24,8,0,13,5,-4,13,6,13,18
.code
main Proc  Far
    Mov    eCx, 10
    Mov    eSi, Offset src ; eSi = src
    Mov    eDi, Offset src ; eDi = src
    Cld
                           ; do {
do: LodsD                  ;   eAx = *eSi++
    Mul    eAx             ;   eAx = eAx * eAx
    StosD                  ;   *eDi++ = eAx
while:                     ; }while (--eCx!=0);
    loop   do

    invoke ExitProcess, 0
main endp
     End   main
.data
    src dword 24,8,0,13,5,-4,13,6,13,18

.code
main Proc  near
    Mov    eCx, 10
    Mov    eSi, Offset src; eSi = src
                         ; do {
do: Mov    eAx, [eSi]    ;   eAx = *eSi
    Mul    eAx           ;   eAx = eAx * eAx
    Mov    [eSi], eAx    ;   *eSi = eAx
    Add    eSi, 4        ;   eSi++
while:                   ; } while(--eCx!=0);
    loop   do

    invoke ExitProcess, 0
main endp
     End   main

1. (10)    Find the greatest 32-bit value in the src array and store in eAx. Hint: Use ScasD for string operation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

2. (10)    Change all the entries that are 13 in array src to 10.