Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.         int notas[10][4];
  6.         int medias[10];
  7.         int ibuf = 0;
  8.         char* decformat = "%d";
  9.         char* strformat = "%s";
  10.         char* askstr = "Enter com a nota %d do aluno %d: ";
  11.         char* mediastr = "Media do aluno %d: %d";
  12.         char* aprov = " - Aprovado.\n";
  13.         char* reprov = " - Reprovado.\n";
  14.         char* newline = "\n";
  15.  
  16.         __asm
  17.         {
  18.                 xor ecx,ecx;
  19.         inputloop:
  20.           notaloop:
  21.                  mov edi, printf;
  22.                  push ecx;
  23.                  movzx ebx,ch;
  24.                  inc ebx;
  25.                  push ebx;
  26.                  movzx ebx,cl;
  27.                  inc ebx;
  28.                  push ebx;
  29.                  mov ebx, askstr;
  30.                  push ebx;
  31.                  call edi;
  32.                  add esp,12;
  33.                  pop ecx;
  34.  
  35.                  push ecx;
  36.                  lea ebx,ibuf;
  37.                  push ebx;
  38.                  mov ebx,decformat;
  39.                  push ebx;
  40.                  mov edi,scanf;
  41.                  call edi;
  42.                  add esp,8;
  43.                  pop ecx;
  44.  
  45.                  lea ebx, notas;
  46.                  xor eax,eax;
  47.                  mov al,4;
  48.                  mul cl;
  49.                  mov dx,ax;
  50.                  mov ax,16;
  51.                  mul ch;
  52.                  add ax,dx;
  53.                  mov edx,ibuf;
  54.                  mov [ebx+eax], edx;
  55.  
  56.                  push ecx;
  57.                  mov edi,printf;
  58.                  mov ebx,newline;
  59.                  push ebx;
  60.                  call edi;
  61.                  add esp,4;
  62.                  pop ecx;
  63.           inc cl;
  64.           cmp cl,4;
  65.           jb notaloop;
  66.         mov cl,0;
  67.         inc ch;
  68.         cmp ch,10;
  69.         jb inputloop;
  70.         }
  71.  
  72.         __asm
  73.         {
  74.                 xor ecx,ecx;
  75.                 xor edx,edx;
  76.                 lea edi, notas;
  77.         sna:
  78.          sn:
  79.                 push edx;
  80.                 xor eax,eax;
  81.                 mov al,4;
  82.                 mul cl;
  83.                 mov dx,ax;
  84.                 mov ax,16;
  85.                 mul ch;
  86.                 add ax,dx;
  87.                 pop edx;
  88.  
  89.                 mov ebx, [edi+eax];
  90.                 add edx, ebx;
  91.                
  92.          inc cl;
  93.          cmp cl,4;
  94.          jb sn;
  95.  
  96.         lea eax,medias;
  97.         push ecx;
  98.         movzx ecx,ch;
  99.         mov [eax+ecx*4],edx;
  100.         pop ecx;
  101.         xor edx,edx;
  102.  
  103.         mov cl,0;
  104.         inc ch;
  105.         cmp ch,10;
  106.         jb sna;
  107.         }
  108.  
  109.         __asm
  110.         {
  111.                 mov edi,printf;
  112.                 xor ecx,ecx;
  113.         pma:
  114.                 lea ebx,medias;
  115.                 mov eax,[ebx+ecx*4];
  116.                 mov dl,4;
  117.                 div dl;
  118.                 movzx eax,al;
  119.                 cmp eax,60;
  120.                 mov ebx,reprov;
  121.                 jb ra;
  122.                 mov ebx,aprov;
  123.                 ra:
  124.                 mov esi,ecx;
  125.                 push ebx;
  126.  
  127.                 push eax;
  128.                 inc ecx;
  129.                 push ecx;
  130.                 dec ecx;
  131.                 mov ebx,mediastr;
  132.                 push ebx;
  133.                 call edi;
  134.                 add esp,12;
  135.  
  136.                 call edi;
  137.                 add esp,4;
  138.                
  139.                 mov ecx,esi;
  140.        
  141.         inc ecx;
  142.         cmp ecx,10;
  143.         jb pma;
  144.         }
  145.  
  146.         __asm
  147.         {
  148.                 mov edi,getchar;
  149.                 call edi;
  150.         }
  151.         return 0;
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement