Use a loop instruction with indirect addressing to reverse the elements of an ar
ID: 3734818 • Letter: U
Question
Use a loop instruction with indirect addressing to reverse the elements of an array in place . - Do not copy the elements to any other array. - Use the SIZEOF, TYPE, and LENGTHOF operators to make the program as flexible as possible if the array size and type should be changed in the future. - Use the XCHG instruction. - The array’s elements are : “ B ” , “ A ” , “ D ” , “ C ” , “ F ” , “ E ” , “ H ” , “ G ” . - The array’s elements after running the program should look like: A, B, C, D, E, F, G,
Using Visual Studios in assembly language!
Explanation / Answer
Data Segment arr1 dw 'G','L','S','I','C','T' arrlen1 dw $-arr1 arr2 dw 20 dup(''),'$' arrlen2 dw $-arr2 Data Ends Code Segment Assume cs:code, ds:data Begin: mov ax, data mov ds, ax mov es, ax mov cx, arrlen1 std lea si, arr1+10 lea di, arr2+10 rep movsw Print: mov ah, 09h lea dx, arr2 int 21h Exit: mov ax, 4c00h int 21h Code Ends End Begin
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.