can anyone help explain or show me how to use an array properly in Microsoft visual as i have no idea where i am going with it at the moment or how to properly get the array into the stack.
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
int main(void)
{
char module[] = "Enter the mark for module:";
char mark[] = "Show Best mark:";
char format[] = "%d";
char formatnumber[] = "%d\n";
int x;
int myarray[6]; // declaration of an array of integers
myarray[1] = 0; // initialise the array
myarray[2] = 0;
myarray[3] = 0;
myarray[4] = 0;
myarray[5] = 0;
myarray[6] = 0;
_asm {
lea ebx, myarray // address of the array (its 0th element) is put in ebx
mov ecx, 5 // size of the array is saved in the counter
mov eax, 0 // eax will be used to hold the sum, initialise to 0
Loop1: add eax,[ebx] // read an element of the array at the address stored in ebx
add ebx, 4 // int occupies 4 bytes (32 bits) // so to read next element increase address in ebx by 4
lea eax, module // this will ask for the number you would like to set in the assembler.
push eax // this will push the number you have given into the stack.
call printf // call printf will then call the parameter for the stack.
add esp, 4
lea eax,
push eax
lea eax, format
push eax
call printf
add esp, 8
loop Loop1 // the end of the loop
return 0;
}