You are on page 1of 19

INTRODUCCIN

En este programa utilizaremos la programacin hbrida la cual, es utilizada en los casos en donde el cdigo en ensamblador dificulta la estructuracin del programa. La programacin hbrida proporciona un mecanismo por medio del cual podemos aprovechar las ventajas del lenguaje ensamblador y los lenguajes de alto nivel, todo esto con el fin escribir programas ms rpidos y eficientes.

C++
C++ Se utilizo un lenguaje de medio nivel como lo es el c++, que nos permite trabajar tanto en lenguajes de alto como de bajo nivel, en este caso con uno de bajo nivel como lo es el lenguaje ensamblador.

ENLACE PARA LA UTILIZACION D


ASM El __asm palabra clave invoca el ensamblador y puede aparecer cuando una C o C + + es la declaracin legal. No puede aparecer por s mismo. Debe ser seguido por una instruccin de montaje, un grupo de instrucciones entre llaves, o, al menos, un par de llaves vaco. El trmino " __asm bloque "se refiere a cualquier instruccin o grupo de instrucciones, est o no entre llaves. Sintaxis: __asm montaje instruccin [;] __asm { montaje instruccin de lista } [;]

EJEMPLO: __asm {

mov al, 2
mov dx, 0xD007 por dx, al }

jae inicio2
}

//---------------------------------------------------------------------------

#include

<vcl.h> #include <stdlib.h> #include <conio.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------#pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)

void TForm1::ordenar() { int i = 0, j = 0, length = 10;

int aux = numeros[i];


int aux2 = numeros[1]; int aux3; int aux4;

_asm { inicio:

mov ecx, length


mov esi, i add j, esi add j, 1

_j: mov ecx, length cmp j, ecx

mov edx, aux2


jb verificar jae validar

verificar: mov aux, edx cmp eax, aux

jb mover
mov aux3, eax mov aux4, edx jae auxiliar

mover: mov aux2, edx mov aux, eax mov eax, aux2

mov edx, aux


mov aux, eax mov aux2, edx mov aux3, eax mov aux4, edx }

_asm { inicio3:

mov eax, aux3


mov edx, aux2 jmp _j

//asignar:
}

_asm { regresar: jmp inicio } _asm { validar: inc i mov esi, i

mov j, esi add j, 1

cmp j, 10d jae salir }

aux2 = numeros[j]; aux = numeros[i]; _asm

{
jmp inicio2 } _asm { salir: } mostrar(); }

void TForm1::mostrar () { reNumeros->Lines->Clear();

for (int x = 0; x < 10; x++)


reNumeros->Lines->Add(IntToStr ( numeros[x] )); }

void __fastcall TForm1::RandomClick(TObject *Sender) { reDes->Lines->Clear(); for (int x = 0; x < 10; x++) numeros[x] = 0; for (int i = 0; i < 10; i++) { numeros[i] = random(20); reDes->Lines->Append(numeros[i]); } }

void __fastcall TForm1::btnCalcularClick(TObject *Sender) { ordenar ();

this->Canvas->Pen->Color = clBlack;
}

void __fastcall TForm1::btnOkClick(TObject *Sender) { int num = edNumero->Text.ToIntDef(5); cont++;

if ( cont <= 10 ) { reDes->Lines->Add( num ); numeros [ cont - 1] = num; } else if (cont > 10) { edNumero->Enabled = false; ShowMessage ("Se han completado los 10 numeros"); cont = 0; } edNumero->Clear(); edNumero->Focused(); }

void __fastcall TForm1::LimpiarClick(TObject *Sender) { reDes->Clear(); reNumeros->Clear(); for (int i = 0; i<10; i++) numeros[i]=0; edNumero->Clear(); edNumero->Enabled = true; cont = 0; }

You might also like