Witam,
chciałbym stworzyć program taki jak poniżej, ale napisany w asemblerze:
using namespace std;
class cKlasa {
public:
int a;
int b;
virtual int dodaj(){
}
};
class cKlasaPochodna :public cKlasa{
public:
int dodaj(){
return(a+b);
}
};
int main(){
cKlasaPochodna obiekt;
obiekt.a=2;
obiekt.b=4;
obiekt.dodaj();
}
Niestety nie mam pojęcia jak w Asemblerze tworzy się klasy, to co stworzyłem do tej pory, to taki program napisany w VS:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Program Name: Template.asm
; Program Description:
; Author:
; Date:
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
; declare variables here
.code
_this$ = -4 ; size = 4
_sStruktura_dodaj PROC ; sStruktura::dodaj, COMDAT
push ebp
mov ebp, esp
push ecx
mov DWORD PTR _this$[ebp], ecx
mov eax, DWORD PTR _this$[ebp]
mov eax, DWORD PTR [eax]
mov ecx, DWORD PTR _this$[ebp]
add eax, DWORD PTR [ecx+4]
mov esp, ebp
pop ebp
ret 0
_sStruktura_dodaj ENDP ; sStruktura::dodaj
_obiekt$ = -8 ; size = 8
_main PROC
push ebp
mov ebp, esp
sub esp, 8
lea ecx, DWORD PTR _obiekt$[ebp]
call _sStruktura
lea ecx, DWORD PTR _obiekt$[ebp]
call _sStruktura_dodaj ; sStruktura::dodaj
xor eax, eax
mov esp, ebp
pop ebp
ret 0
_main ENDP
_this$ = -4 ; size = 4
_sStruktura PROC ; sStruktura::sStruktura, COMDAT
push ebp
mov ebp, esp
push ecx
mov DWORD PTR _this$[ebp], ecx
mov eax, DWORD PTR _this$[ebp]
mov DWORD PTR [eax], 2
mov ecx, DWORD PTR _this$[ebp]
mov DWORD PTR [ecx+4], 4
mov eax, DWORD PTR _this$[ebp]
mov esp, ebp
pop ebp
ret 0
_sStruktura ENDP ; sStruktura::sStru
INVOKE ExitProcess,0
END _main
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
using namespace std;
struct sStruktura {
int a=2;
int b=4;
int dodaj(){
return (a+b);
};
};
int main(){
sStruktura obiekt;
obiekt.dodaj();
}
Z góry dziękuję, za wszelkie sugestie. Dopiero zaczynam przygodę z programowaniem.