Computing.Net > Forums > Programming > Assembly Language

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Assembly Language

Reply to Message Icon

Name: indigo99
Date: May 18, 2004 at 04:38:26 Pacific
OS: Win 2000
CPU/Ram: 512
Comment:

Hello, I was wondering if someone could help me! I am writing a program in Assembly Language and I am stuck. The memory arrays keep over flowing and I can't see where the problem might be!. The program complies fine it is when you run it that u see the problem!

/*This program will create an assembly language de-coding program to deduce results of simple calculations*/
#include <string.h>
#include <stdio.h>
#include <io.h>
#include <stdlib.h>
#include <iostream.h>
#include <conio.h>


char main_memory[99][30]={""};

FILE *stream;
char msg[30]=" ";
char temp1[30]="EOF";
int i;
int count=0;
char token[6];
int count_token=1;
char Primary_String[20];
char Sub_String[20];
int j = 0;
int count_position=0;
int Sub_String_Position=0;
int String_remainder_pos=0;
int String_size;
int Integer_remainder=0;
char temp;
char Cut_Sub_String[26]="";
char Cut_String_Remainder[26]="";
char code_keys[7][7]= {""};
int t=0;
char token_code[4];
char token_value[4];

void set_code_keys(void)
{
strcpy (code_keys[0],"ADR");
strcpy (code_keys[1],"LIT");
strcpy (code_keys[2],"STORE");
strcpy (code_keys[3],"ADD");
strcpy (code_keys[4],"SUB");
strcpy (code_keys[5],"MUL");
strcpy (code_keys[6],"DIV");

}

void start_token(void)
{
strcpy(token,main_memory[0]);
}

void get_next_token(void)
{
strcpy(token,main_memory[count_token]);
count_token++;
}

void string_test(void)
{
Cut_Sub_String[20]=NULL;
Cut_String_Remainder[20]=NULL;
Sub_String_Position = 0;
count_position=0;
String_remainder_pos=0;
t=0;


strcpy(Primary_String,token);

for (t=0; t<6; t++)
{
strcpy(Sub_String, code_keys[t]);

String_size=strlen(Primary_String);

for (j=0; j<String_size; j++)
{

if (Primary_String[j] == Sub_String[count_position])
{
Cut_Sub_String[Sub_String_Position]=Primary_String[j];

}
if (Primary_String[j] != Sub_String[count_position])
{
temp=Primary_String[j];
Cut_String_Remainder[String_remainder_pos]=temp;
String_remainder_pos++;


}

Sub_String_Position++;
count_position++;


}
if (strcmp(Sub_String, Cut_Sub_String)==0)
{

strcpy(token_code, Cut_Sub_String);
strcpy(token_value,Cut_String_Remainder);
printf("%s", token_code);
printf("\n");
printf("%s", token_value);

// printf("Match");
}
}
//Integer_remainder=atoi(Cut_String_Remainder);

}

void get_info_from_file(void)
{
//Open a file for update
stream = fopen("INPUT.txt","r+");

//seek to the start of the file
fseek(stream, 0, SEEK_SET);

//Read a string from a file
while(strcmp(msg,"EOF\n") !=0)
{
fgets(msg,30,stream);
strcpy(main_memory[count], msg);
count++;
}

//{
//printf("%s", main_memory[i]);
//}
fclose(stream);
}

void main(void)
{
get_info_from_file();

set_code_keys(); // Call to the set_code_keys function

start_token(); // call to the start_token function

string_test();
getch();
get_next_token();
string_test();
getch();

return;

}


Emer McLysaght




Sponsored Link
Ads by Google

Response Number 1
Name: Sord
Date: May 18, 2004 at 19:17:58 Pacific
Reply:

That's definatelly not assembly


0

Response Number 2
Name: Sord
Date: May 18, 2004 at 21:55:23 Pacific
Reply:

Sorry to post so fast without looking at it. It seems like your arrays are too small. You may want to try getting the length of the file or whatever and sizing your arrays correctly after that.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Assembly Language

Assembly Language Help please? www.computing.net/answers/programming/assembly-language-help-please/4705.html

revolutionary guide to assembly language www.computing.net/answers/programming/revolutionary-guide-to-assembly-language/1303.html

Assembly Language - Cont www.computing.net/answers/programming/assembly-language-cont/7516.html