Re: Встроенный в С++ Ассемблер.Решите задачку?
Добавлено: 04 июл 2008, 13:02
и что теперь не работает?
форум программистов
https://www.developing.ru/
Код: Выделить всё
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
void ClearAll(); // o4istka soderzhimogo
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void ClearAll()
{
Form1->StringGrid1->Rows[0]->Clear();
Form1->StringGrid1->ColCount = 5;
int i;
for(i=0;i<5;++i)
{
Form1->StringGrid1->Cells[i][0]="";
}
Form1->StatusBar1->SimpleText="Введите элемнты массива X";
return;
}
//-------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ClearAll();
}
//---------------------------------------------------------------------------
int max(int a, int b)
{
asm
{ mov eax,a;
cmp eax,b;
je L;
jmp exit;
}
L:
asm
{
mov eax,b;
}
exit:
}
//----------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{int i,j;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
Edit1->Text = max(StrToInt(int a, int b));
}
//---------------------------------------------------------------------------
Код: Выделить всё
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
void ClearAll();
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void ClearAll()
{
Form1->StringGrid1->Rows[0]->Clear();
Form1->StringGrid2->Rows[0]->Clear();
Form1->StringGrid1->ColCount=5;
Form1->StringGrid2->ColCount=5;
int i;
for(i=0;i<5;i++)
{
Form1->StringGrid1->Cells[0][i]="";
Form1->StringGrid2->Cells[0][i]="";
}
return;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ClearAll();
}
//---------------------------------------------------------------------------
int min(int a, int b)
{
asm
{ mov eax,a;
cmp eax,b;
jge L;
jmp exit; }
L:
asm
{ mov eax, b; }
exit:
}
//---------------------------------------------------------------------------
int add(int a, int b)
{
asm
{ mov eax, a;
or eax, b; }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int tmp1,tmp2;
int i,j;
tmp1 = StrToInt(StringGrid1->Cells[0][0]);
for (j=0;j<5;j++)
{tmp1 = min(tmp1, StrToInt(StringGrid1->Cells[j][0]));}
Edit1->Text = tmp1;
tmp2 = StrToInt(StringGrid2->Cells[0][0]);
for(j=0;j<5;j++)
{tmp2 = min(tmp2, StrToInt(StringGrid2->Cells[j][0]));}
Edit2->Text = tmp2;
Edit3->Text = add(tmp1,tmp2);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N1Click(TObject *Sender)
{
ShowMessage(AnsiString(" ... "));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N2Click(TObject *Sender)
{
Application -> Terminate();
}
//----------------------------------------------