ASEMBLER probleme

Acest forum este dedicat intrebarilor de programare care nu-si au locul in unul din celelalte forumuri
Post Reply
davidush
Junior
Junior
Posts: 7
Joined: 12 Jan 2016, 23:32
Judet: Iaşi

ASEMBLER probleme

Post by davidush » 21 Feb 2016, 03:20

Code: Select all

#include "stdafx.h"
#include <iostream>

using namespace std;

void GetNumberOfZeroAndOne(unsigned int n, unsigned int *z, unsigned int *o)
{
    _asm
    {
        mov eax, [ebp + 8];
        mov esi, 0;				// numar zerouri
        mov edi, 0;				// numar unu
        mov ebx, 2;
    start_while:
        cmp eax, 0;
        je exit_while;
        mov edx, 0;
        div ebx;
        cmp edx, 0;
        je count_zero;
        inc edi;
        jmp start_while;
    count_zero:
        inc esi;
        jmp start_while;
    exit_while:
        mov ebx, [ebp + 12];
        mov[ebx], esi;
        mov ebx, [ebp + 16];
        mov[ebx], edi;
    }
}

int main()
{
    unsigned int n, zero = 0, one = 0;
    cin >> n;
    GetNumberOfZeroAndOne(n, &zero, &one);
    cout << zero << ' ' << one << '\n';
    return 0;
}

Code: Select all

 #include "stdafx.h"
 #include <iostream>
 #include <cstring>
 
 using namespace std;
 
 int GetNumarVocaleConsoane(char *s)
 {
	int a = strlen(s);
	_asm
	{
 mov ebx, [ebp + 8];
 mov ecx, 0;
 mov esi, 0;
 mov edi, 1;
 mov eax, a;
 dec eax;
	start_for:
 cmp ecx, eax;
 je exit_for;
 cmp byte ptr [ebx + ecx], 'a';
 je check_next;
 cmp byte ptr[ebx + ecx], 'e';
 je check_next;
 cmp byte ptr[ebx + ecx], 'i';
 je check_next;
 cmp byte ptr[ebx + ecx], 'o';
 je check_next;
 cmp byte ptr[ebx + ecx], 'u';
 je check_next;
 cmp byte ptr[ebx + ecx], 'A';
 je check_next;
 cmp byte ptr[ebx + ecx], 'E';
 je check_next;
 cmp byte ptr[ebx + ecx], 'I';
 je check_next;
 cmp byte ptr[ebx + ecx], 'O';
 je check_next;
 cmp byte ptr[ebx + ecx], 'U';
 je check_next;
 inc ecx;
 inc edi;
 jmp start_for;
	check_next:
 cmp byte ptr[ebx + edi], 'a';
 je next_step;
 cmp byte ptr[ebx + edi], 'e';
 je next_step;
 cmp byte ptr[ebx + edi], 'i';
 je next_step;
 cmp byte ptr[ebx + edi], 'o';
 je next_step;
 cmp byte ptr[ebx + edi], 'u';
 je next_step;
 cmp byte ptr[ebx + edi], 'A';
 je next_step;
 cmp byte ptr[ebx + edi], 'E';
 je next_step;
 cmp byte ptr[ebx + edi], 'I';
 je next_step;
 cmp byte ptr[ebx + edi], 'O';
 je next_step;
 cmp byte ptr[ebx + edi], 'U';
 je next_step;
 cmp byte ptr[ebx + edi], ' ';
 je next_step;
 jmp count_pair;
	next_step:
 inc ecx;
 inc edi;
 jmp start_for;
	count_pair:
 inc esi;
 inc ecx;
 inc edi;
 jmp start_for;
	exit_for:
 mov eax, esi;
	}
 }
 
 int main()
 {
	char *s = "Azi am examen la arhitectura";
	int rez;
	_asm
	{
 push s;
 call GetNumarVocaleConsoane;
 add esp, 4;
 mov rez, eax;
	}
	cout << rez << '\n';
 return 0;
 }
 
daca va mai intereseaza am mai rezolvat cateva astept pareri :D :D



Post Reply