Hi folks! :)
I'm here with a problem of Assembly 8086 (x86) (NASM). I´m trying calculate the sum of all numbers, which are odd, lowers than X (X = number defined by user)
Already solved the problem in C # and C + +, but i need the Assembly Code.
In C#:
int num = 0;
int res = 0;
int all = 0;
int soma = 0;
num = Convert.ToInt32(Console.ReadLine());
while (all < num)
{
all++;
res = all % 2;
if (res == 1)
{
soma += all;
}
else
{
continue;
}
}
Console.WriteLine(soma);
In C++:
int num = 0;
int all = 0;
int res = 0;
int soma = 0;
puts("Introduza o valor: ");
scanf_s("%d", &num);
while (all < num)
{
all++;
res = all % 2;
if (res ==1)
{
soma += all;
}
else
{
continue;
}
}
printf("Soma valores impares: %d",soma);
In Assembly:
%include "arq2010.asm"
LEA CX, [MSG1] ;Show MSG1
CALL WriteLine
LEA CX, [input] ;Read Input
CALL ReadString
;Most create the condition here!
.DATA
MSG1 DB "Input: ", 0
MSG2 DB "Output: ", 0
Appreciate help. Thanks! :)