I have a C program and I am trying to change this program to visual c++

This C program about the Execute Assembly Instructions. And I will change this to Visual C++ on form screen. Can anybody help me?
Could you be more precise ?
I did a C program.You can enter to this program assembly instructions and than you can execute this instructions. And now I am trying to this program in visual c++. But I have some problems. if you know C, visual C++ and a little assembly, can you help me? I will show you my program
Post your program here...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#include<stdio.h>
#include<conio.h>
//#include<iostream.h>
#include<string.h>
#include<stdlib.h>
typedef unsigned int word;
typedef unsigned char byte;

word M[4096];
word PC;
word AR;
word DR;
word TR;
byte OUTR;
byte INPR;
byte SC;
byte S;
byte R;
byte IEN;
byte FGI;
byte FGO;
byte D[8];
byte T[8];
byte B[12];
byte I,II,RR,r,p,E,D7,T0,T1,T2;

union {
struct {
	unsigned b0:1;unsigned b1:1;unsigned b2:1;unsigned b3:1;
	unsigned b4:1;unsigned b5:1;unsigned b6:1;unsigned b7:1;
	unsigned b8:1;unsigned b9:1;unsigned b10:1;unsigned b11:1;
	unsigned opr:3;
	unsigned I:1;
       }b;
unsigned ar:12;
unsigned deg;
}IR;

union {
struct {
	unsigned b0:1;
	unsigned x:14;
	unsigned b15:1;
       }b;
unsigned char acl:8;
unsigned deg;
unsigned long t;
}AC;



 void yukle(void)
 {
 char ch;
 unsigned int veri;
 system("cls");
 tekrar:
 printf("enter first address :");
 scanf("%x",&veri);
 AR=veri;
 if(AR>4095 || AR<0) {printf("error\n"); goto tekrar;}
 while(1)
 {printf("%X:",AR);
  scanf("%x",&veri);
  M[AR]=veri;
  AR=AR+1;
  if(veri==1) break;
  }
 }

//Belleði görüntüle
 void dump(void)
 {
 char j,k;
 unsigned int veri;
 unsigned adres;

 system("cls");
 tekrar:
 printf("first adress for dump :");
 scanf("%x",&veri);
 adres=veri;
 if(adres>4095 || adres<0) {printf("error\n"); goto tekrar;}
 for(k=0;k<20;k++){
 printf("%X:",adres);

 for(j=0;j<10;j++){
 printf("%04X ",M[adres]);
 adres++;
 if(j==9) printf("\n");
 }
 }
// getch();
 }



 void execute(void)
 { unsigned char j,ch;
   unsigned int adres;
   unsigned long top;
   unsigned int veri;
   int aaaa;


 AR=0;
 DR=0;
 AC.deg=0;
 TR=0;
 OUTR=0;
 INPR=0;
 IR.deg=0;
 OUTR=0;
 INPR=0;
 SC=0;
 R=0;
 IEN=0;
 FGI=0;
 FGO=0;
 E=0;
 S=1;
 system("cls");
 tekrar:
 printf("first address for execute :");
 scanf("%X",&veri);
 adres=veri;
 if(adres>4095 || adres<0) {printf("error\n"); goto tekrar;}

 PC=adres;
 //if(adres>4095) exit(1);

 while(S==1)
 {

 for(j=0;j<8;j++){
   if(j==SC) T[j]=1;else T[j]=0;
   }
 /*----------Fetch-----*/
 RR=!R;
 if(RR*T[0]==1) AR=PC;
 if(RR*T[1]==1) {IR.deg=M[AR];PC=PC+1;}
 /*---------Decode--------------------------------------*/
 if(RR*T[2]==1){
 for(j=0;j<8;j++){ if(j==IR.b.opr) D[j]=1; else D[j]=0;}
 AR=IR.ar;
 I=IR.b.I;
 }
 /*---------indirect-----------------------------*/
 //I=IR.b.I;
 D7=!D[7];
 if(D7*I*T[3]==1) AR=M[AR];
 /*---------interrupt--------*/
 T0=!T[0];T1=!T[1]; T2=!T[2];
 //if(T0*T1*T2*IEN==1 && (FGI || FGO)==1) R=1;
   if(T0*T1*T2*IEN*FGI==1 || T0*T1*T2*IEN*FGO==1) R=1;
 if(R*T[0]==1) {AR=0;TR=PC;}
 if(R*T[1]==1) {M[AR]=TR;PC=0;}
 if(R*T[2]==1) {PC=PC+1;IEN=0;R=0;}
 /*-----------------memory reference instruction-------*/
 /*AND*/
 if(D[0]*T[4]==1) DR=M[AR];
 if(D[0]*T[5]==1) {AC.deg=AC.deg & DR;}
 /*ADD*/
 if(D[1]*T[4]==1) DR=M[AR];
 if(D[1]*T[5]==1) {AC.t=AC.deg+DR;if(AC.t>65535) E=1;else E=0;}
 /*LDA*/
 if(D[2]*T[4]==1) DR=M[AR];
 if(D[2]*T[5]==1) {AC.deg=DR;}
 /*STA*/
 if(D[3]*T[4]==1) {M[AR]=AC.deg;}
 /*BUN*/
 if(D[4]*T[4]==1) {PC=AR;}
 /*BSA*/
 if(D[5]*T[4]==1) {M[AR]=PC;AR=AR+1;}
 if(D[5]*T[5]==1) {PC=AR;}
 /*ISZ*/
 if(D[6]*T[4]==1) DR=M[AR];
 if(D[6]*T[5]==1) DR=DR+1;
 if(D[6]*T[6]==1) {M[AR]=DR;if(DR==0)PC=PC+1;}
 /*-----register referecce instruction-----*/
 II=!IR.b.I;
 r=D[7]*II*T[3];
 B[0]=IR.b.b0;B[1]=IR.b.b1;B[2]=IR.b.b2;B[3]=IR.b.b3;B[4]=IR.b.b4;B[5]=IR.b.b5;
 B[6]=IR.b.b6;B[7]=IR.b.b7;B[8]=IR.b.b8;B[9]=IR.b.b9;B[10]=IR.b.b10;B[11]=IR.b.b11;

 /*CLA*/
 if(r*B[11]==1) AC.deg=0;
 /*CLE*/
 if(r*B[10]==1) E=0;
 /*CMA*/
 if(r*B[9]==1) {AC.deg=~AC.deg;}
 /*CME*/
 if(r*B[8]==1) E=!E;
 /*CIR */
 if(r*B[7]==1) {AC.b.b15=E; E=AC.b.b0;AC.deg=AC.deg>>1;}
 /*CIL*/
 if(r*B[6]==1) {AC.b.b0=E; E=AC.b.b15;AC.deg=AC.deg<<1;}
 /*INC*/
 if(r*B[5]==1) AC.t=AC.deg+1;
 /*SPA*/
 if(r*B[4]==1) if(AC.b.b15==0) PC=PC+1;
 /*SNA*/
 if(r*B[3]==1) if(AC.b.b15==1) PC=PC+1;
 /*SZA*/
 if(r*B[2]==1) if(AC.deg==0) PC=PC+1;
 /*SZE*/
 if(r*B[1]==1) if(E==0) PC=PC+1;
 /*HLT*/
 if(r*B[0]==1) {S=0;goto son;}
 /*------------input/output--------------*/
 I=IR.b.I;p=D[7]*I*T[3];
 /*INP*/
 if(p*B[11]==1) AC.acl=INPR;FGI=0;
 /*OUT*/
 if(p*B[10]==1) OUTR=AC.acl;FGO=0;
 /*SKI*/
 if(p*B[9]==1)  if(FGI==1) PC=PC+1;
 /*SKO*/
 if(p*B[8]==1)  if(FGO==0) PC=PC+1;
 /*ION*/
 if(p*B[7]==1)  IEN=1;
 /*IOF*/
 if(p*B[6]==1)  IEN=0;
 //if(p==1) SC=0;

 if(SC<7) SC++;else SC=0;
 if(SC==0){
 printf("AC:%x AR:%x DR:%x IR:%x PC:%x \n",AC.deg,AR,DR,IR.deg,PC);
 ch=getch();
 if(ch=='D' || ch=='d')  S=1;else S=0;
 }

 }//while
 son:
 aaaa=5;

 }

 main()
 {
 char sec;
 unsigned int j;
 FILE *f;
 //yukle();
 //dump();
 //execute(0100);

 for(j=0;j<4096;j++) M[j]=0;

 while(1)
 {
 system("cls");
 printf("******MENU*******\n");
 printf("1.new program\n");
 printf("2.save\n");
 printf("3.enter program from file\n");
 printf("4.Memory dump\n");
 printf("5.execute\n");
 printf("6.Exit\n\n");
 printf("Select number :");
 sec=getche();
 printf("\n");

 switch(sec)
 {
 case '1':yukle();break;
 case '2':{
	printf("prog.txt saving.....\n");
	f=fopen("prog.txt","w");
	for(j=0;j<4096;j++) fprintf(f,"%d\n",M[j]);
	fclose(f);
	printf("Dosya kaydedildi\n");
	};break;
 case '3':{
	printf("prog.txt uploaded...\n");
	f=fopen("prog.txt","r");
	for(j=0;j<4096;j++) fscanf(f,"%d",&M[j]);
	fclose(f);
	printf("Okay\n");
	};break;

 case '4':dump();break;
 case '5':execute();break;
 case '6':exit(1);break;
 }
 getch();
 }
 /*
 IR.deg=0x8800;
 IR.b.opr=7;
 IR.ar=0x008;
 IR.b.I=0;
 printf("%x %x %x %x %x %x\n",IR.deg,IR.b.I,IR.b.opr,IR.ar,IR.b.b11,IR.b.b0);
 */
 getch();


 return 0;
 }
Topic archived. No new replies allowed.