Re: lug-bg: C++ & Assembler
- Subject: Re: lug-bg: C++ & Assembler
- From: Georgi Ivanov <genius@xxxxxxxxxxxxxx>
- Date: Sun, 17 Oct 2004 02:27:57 +0300
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dimitar Terziev wrote:
| <0< 70 7040G0 40 =0?@02O ?@>3@0<:0 =0 0A5<1;5@, 45B> >B B@8 G8A;0
8725640
| =09-3>;O<>B>. ! ?8A0=5B> =0 :>40 =O<0E ?@>1;5< - ?8A0E 3> 2J2 Visual
C++ 2
| >70B0. <0 2:JI8 =O<0< 1>70.... B0 2J?@>A0 5 :0: 2J2 KDevelop
=0?@8<5@ A5
| 2J25640B 0A5<1;5@A:8 8=AB@C:F88? >40 5 A;54=8OB:
|
| <cut>
| ">20 =5I> 10G:0 2 1>70B0. 10G5 E8G =5 <8 A5 8A:0 40 A8 8=AB0;8@0<
1>70 A0<>
| 70 40 ?8H0 ?@>AB>B88 =0 0A5><1;5@, 0 8A:0< 40 A8 38 ?@02O 2 8=C:A.
J?@>A0
| <8 5 :0:? @>120E 40 70?8H0 8=AB@C:F88B5 ?> A;54=8O =0G8=:
|
| __asm__ (
|
| "mov eax,a"
| .....
| .....
| .....
| );
|
| 5 AB020. C-B> =5 3> 7=0< <=>3> 4>1@5, 0<0 2A5 ?0: A5 A?@02O<.... B0,
:0: A5
| 2J25640B 0A5<1;5@A:8 8=AB@C:F88, :>8B> 40 A5 2J7?@85<0B >B :><?8;0B>@0 =0
| KDevelop? ;8 ?@>AB> B@O120 40 8<0 >I5 =O:>5 #include? :> =O:>9
?><>35=5 -
| I5 8<0< 40 G5@?O =O:>;:> 18@8 :)
|
| #include <iostream.h>
| int prov(int a, int b, int c) {
| int max;
| _asm {
|
| mov eax,a
| mov ebx,b
| mov ecx,c
| mov max,ebx
| cmp eax,ebx
| jle end
| mov max,eax
| cmp ecx,max
| jle end1
| mov max,ecx
|
| end1:
|
| end:
| cmp ecx,max
| jle end2
| mov max,ecx
|
| end2:
|
| }
|
| return max;
| }
|
| int main() {
| int a,b,c,res;
| cout << "Enter a: ";
| cin >> a;
| cout << "Enter b: ";
| cin >> b;
| cout << "Enter c: ";
| cin >> c;
| res = prov(a,b,c);
| cout<<"Max="<< res << endl;
| return 0;
| }
|
| </cut>
============================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers).
http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora
To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
============================================================================
За C е приблизително така :
#include <stdio.h>
typedef struct{
~ int y;
~ char z[4];
}foome;
int foobar(foome *foo, foome *bar)
{
~ printf("foo.y = %d\tfoome.y = %d\n", foo->y, bar->y);
~ bar->y = foo->y;
~ return 1000;
};
int main(int argc, char **argv)
{
~ foome foo, bar;
~ int x = 0;
~ foo.y = 10;
~ bar.y = 20;
~ asm("push %1; push %2; call foobar; movl %%eax, %0;"
~ : "=r" (x) //the output variables
~ : "r" (&bar), "r" (&foo) //the input varialbes
~ : "%eax" ); //the registers we dirty up );
~ printf("foobar returned %d\nfoo.y = %d\tbar.y = %d\n", x, foo.y,
bar.y);
~ return 0;
}
- --
Georgi Ivanov
System Administrator
Aii Data Processing
IT Department
http://6lyokavitza.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (FreeBSD)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBca580dEkp0mjhDsRAiE+AJ0cqlvItAsTKmJ5wg3V2s/5uA08DQCfT1HI
5UkH/UnP0DLodW2y578eAy8=
=lWU4
-----END PGP SIGNATURE-----
============================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers).
http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora
To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
============================================================================
|