Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SECTION .data ; /* contains initialized data */
- a DD 4,1,4,2,4,3,4,5 ; int a[][2] = { {4,1}, {4,2}, {4,3}, {4,5} };
- i DD 2 ; int i = 2;
- SECTION .bss ; /* contains uninitialized data */
- b RESD 1 ; int b;
- rslt RESD 1 ; int rslt;
- SECTION .text ; /* contains code
- GLOBAL _start ;
- _start: ; void main(void){
- nop ; /* do not remove the "nop" */
- mov ecx, [i] ; /* i -> ecx Zaehlervariable inner Loop */
- sub ebx, ebx ; for ( b = 0; /* ebx Zaehlervariable outer Loop */
- outer: cmp ebx, 4 ; b < 4; ++b) /* inkrement folgt spaeter */
- jge endOuter ;
- jecxz outer2 ; /* falls i = 0, ueberspringe innere Scheleife */
- inner: mov [i], ecx ;
- mov edx, ebx ; /* Speicherabbildungsfunktion - benutzte edx um ebx nicht zu überschreiben*/
- shl edx, 1 ; b *= 2;
- add edx, [i] ; b += i;
- add eax, [cs:a+edx*4] ; rslt += a[b][i];
- ; /*a=Anfangsadresse, ebx=Zeile, 2=Spalten, ecx=Spalte, 4=Byte pro Element */
- loopnz inner ; /* loope solange ecx (i) != 0 ist */
- outer2: mov ecx, 2 ; i = 2;
- inc ebx ; b++;
- jmp outer ;
- endOuter: mov [rslt], eax ; /* Zuletzt wird eax in der rslt Variable gespeichert */
- ; return 0;
- end:mov eax, 1 ; /* the exit system call
- mov ebx, 0 ; no errorcode
- int 80h ; execute system call */
- ; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement