Advertisement
Guest User

d

a guest
Apr 28th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.04 KB | None | 0 0
  1. // ConsoleApplication2.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include<iostream>
  6. #include<ctime>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     srand((unsigned)time(NULL));
  13.     int tmb1[20];
  14.     float tmb2[20];
  15.     for (int i = 0; i < 20; i++)
  16.     {
  17.         tmb1[i] = rand() % 200 + 1;
  18.         tmb2[i] = (rand() % 1000 + 1) / 39.0;
  19.     }
  20.  
  21.     char ki[] = "%d - %f";
  22.  
  23.     _asm
  24.     {
  25.         mov ebx, 0;
  26.     for_ciklus:
  27.         mov esi, esp;
  28.         lea eax, [tmb1 + ebx];
  29.         push eax;
  30.         mov esp, esi;
  31.         lea eax, ki;
  32.         push eax;
  33.         call printf;
  34.         pop eax;
  35.         pop eax;
  36.         inc ebx;
  37.         cmp ebx, 20;
  38.         jnz for_ciklus;
  39.     }
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.     /*
  47.     char dani[] = "earth";
  48.     char peti[] = " day";
  49.  
  50.     _asm
  51.     {
  52.     lea eax, dani;
  53.     lea ebx, peti;
  54.     push eax;
  55.     call printf;
  56.     push ebx;
  57.     call printf;
  58.     call DWORD ptr printf;
  59.     pop ebx;
  60.     pop eax;
  61.  
  62.     }
  63.  
  64.     char hi[6] = "Hello";
  65.     char earth[] = "World";
  66.     char text[] = "%s %s %d";
  67.     int a = 5;
  68.  
  69.  
  70.  
  71.     __asm
  72.     { // Remember Inst dest,src
  73.     mov eax, a;
  74.     push eax;
  75.     lea eax, earth; // eax = address of earth
  76.     push eax;   // put eax at the top of the stack
  77.     lea eax, hi;  // eax = address of hi
  78.     push eax;
  79.  
  80.     lea eax, text;
  81.     push eax;
  82.  
  83.     call DWORD ptr printf;
  84.     // or the indierct call
  85.     // mov eax, printf
  86.     // call eax
  87.     pop ebx;// clean up the stack
  88.     pop ebx;
  89.     pop ebx;
  90.     pop ebx;
  91.  
  92.  
  93.     }
  94.  
  95.     // 1.feladat
  96.  
  97.     char* printfszoveg = "%d %f - ";
  98.  
  99.     _asm
  100.     {
  101.     mov ecx, 20;
  102.     mov eax, 0;
  103.     cikluspf:
  104.     push ecx;
  105.     push eax;
  106.     mov esi, esp;
  107.     fld tomb2[eax];
  108.     sub esp, 8;
  109.     fstp qword ptr[ESP];
  110.     push tomb1[eax];
  111.     push printfszoveg;
  112.     call dword ptr printf;
  113.     mov esp, esi;
  114.     pop eax;
  115.     pop ecx;
  116.     add eax, 4;
  117.     loop cikluspf;
  118.     }
  119.  
  120.     //2.feladat
  121.  
  122.     int paros;
  123.     int ketto = 2;
  124.  
  125.     _asm
  126.     {
  127.     mov ecx, 20;
  128.     mov ebx, 0;
  129.     cikluspo:
  130.     mov eax, tomb1[ebx];
  131.     xor edx, edx;
  132.     div ketto;
  133.     cmp edx, 0;
  134.     jne tovabb;
  135.     mov eax, tomb1[ebx];
  136.     add paros, eax;
  137.     tovabb:
  138.     add ebx, 4;
  139.     loop cikluspo;
  140.     }
  141.     cout << endl << paros;
  142.     //3.feladat
  143.  
  144.     float atlagf;
  145.  
  146.     _asm {}
  147.  
  148.     //4.feladat
  149.  
  150.     _asm {}
  151.  
  152.     */
  153.     system("pause");
  154.     return 0;
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement