Új hozzászólás Aktív témák
-
ZTE_luky
aktív tag
Köszönöm szépen a segítséget, hát igen no [] tömböm random meg van határozva, de annál kevesebb értéket is kivehet mint a max, többet nem. Nem tudom az mennyire lehet probléma. Jelenleg se történik semmi, valami ilyesmit kellett kihozni az egészből 14:00-kor kell leadnom, de nem működik, tele van warning-al és nem is csinál semmi értelmeset sajnos. PEdig a kiinduló C-file gyönyörűen működik. Nem tudom mi lehet a baj, eléggé belekeveredtem sajnos.
#include<stdio.h>
#include<string.h>
// ---------- Globale Variablen ----------
int no[] = {0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,
0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B};
// Address array
char string[9]; // String array
int R0; // (--int halt--) 0 Constant
int R1;
int R2; // (--int counter--) Index counter (String)
int R3; // (--int op--) Index Operation-Code
int R4; // (--int state--) Index strings
int R5; // (--int i--) Index counter (Address)
char R6; // (--char c--) Character to getchar
char R7; // (--char r1--) Register 1
char R8; // (--char r2--) Register 2
char R9; // (--char r3--) Register 3
int *RA; // (--int *no0--) BP of Address-array NEW
int *RB; // (--int *noi--) Flexibe Array Pointer NEW
char *RC; // (--char *string0--) BP of String-array NEW
char *RD; // (--char stringi--) Flexibe Array Pointer NEW
int RE; // SIZE 9
int RF; // FFFF
// ---------- Main Function ----------
int main()
{
R0 = 0;
R1 = 1;
R2 = 0;
R4 = 0;
R5 = 0;
RA = &no[0];
RC = &string[0];
RE = 9;
RF = 0xFFFF;
//no0 = &no[R0]; // Zero Element (in array "no") NEW
//string0 = &string[R0]; // Zero Element (in array "string") NEW
// ---------- Program ----------
L0: //init
R2 = R0; //counter
goto L1; //thestring;
L1: //thestring:
if (R2 < RE) // for (counter = 0; counter < 9 ;)
R6 = getchar(); //c
if ( R6 != EOF) //c
goto L2; //ignore;
else {goto L3;} //end
L2: //ignore:
if (R6 != 0x20 && R6 != 0xA) // R6=c
{
R2 += R1; //counter++;
//o++;
goto L1; //thestring;
}
// ---------- Search Function (Operating Code) ----------
// if (string[0] == 0x41 && string[1] == 0x44 && string[2] == 0x44)
if (*RC == 0x41 && *RC + R1 == 0x44 && *RC + R1 + R1 == 0x44) //NEW
{ //----- Function ADD -----
R3 = R1;
R4 += R1;
RB += R1;
R7 = RC + R1 * 4;
R8 = RC + R1 * 6;
R9 = RC + R1 * 8;
printf("%D:%d%c%c%c\n",RB,R3,R7,R8,R9); //Print the current string
}
//else if (string[0] == 0x53 && string[1] == 0x55 && string[2] == 0x42)
else if (*RC == 0x53 && *RC + R1 == 0x55 && *RC + R1 + R1 == 0x42)//NEW
{ //----- Function SUB -----
R3 = R1;
R4 += R1;
RB += R1;
R7 = RC + R1 * 4;
R8 = RC + R1 * 6;
R9 = RC + R1 * 8;
printf("%D:%d%c%c%c\n",RB,R3,R7,R8,R9); //Print the current string
}
//else if (string[0] == 0x41 && string[1] == 0x4E && string[2] == 0x44)
else if (*RC == 0x41 && *RC + R1 == 0x4E && *RC + R1 + R1 == 0x44) //NEW
{ //----- Function AND -----
R3 = R1;
R4 += R1;
RB += R1;
R7 = RC + R1 * 4;
R8 = RC + R1 * 6;
R9 = RC + R1 * 8;
printf("%D:%d%c%c%c\n",RB,R3,R7,R8,R9); //Print the current string
}
//else if (string[0] == 0x58 && string[1] == 0x4F && string[2] == 0x52)
else if (*RC == 0x58 && *RC + R1 == 0x4F && *RC + R1 + R1 == 0x52) //NEW
{ //----- Function XOR -----
R3 = R1;
R4 += R1;
RB += R1;
R7 = RC + R1 * 4;
R8 = RC + R1 * 6;
R9 = RC + R1 * 8;
printf("%D:%d%c%c%c\n",RB,R3,R7,R8,R9); //Print the current string
}
//else if (string[0] == 0x53 && string[1] == 0x48 && string[2] == 0x4C)
else if (*RC == 0x53 && *RC + R1 == 0x48 && *RC + R1 + R1 == 0x4C) //NEW
{ //----- Function SHL -----
R3 = R1;
R4 += R1;
RB += R1;
R7 = RC + R1 * 4;
R8 = RC + R1 * 6;
R9 = RC + R1 * 8;
printf("%D:%d%c%c%c\n",RB,R3,R7,R8,R9); //Print the current string
}
//else if (string[0] == 0x53 && string[1] == 0x48 && string[2] == 0x52)
else if (*RC == 0x53 && *RC + R1 == 0x48 && *RC + R1 + R1 == 0x52) //NEW
{ //----- Function SHR -----
R3 = R1;
R4 += R1;
RB += R1;
R7 = RC + R1 * 4;
R8 = RC + R1 * 6;
R9 = RC + R1 * 8;
printf("%D:%d%c%c%c\n",RB,R3,R7,R8,R9); //Print the current string
}
//else if (string[0] == 0x48 && string[1] == 0x4C && string[2] == 0x54)
else if (*RC == 0x48 && *RC + R1 == 0x4C && *RC + R1 + R1 == 0x54) //NEW
{ //----- Function HLT -----
R3 = R1;
R4 += R1;
RB += R1;
R7 = RC + R1 * 4;
R8 = RC + R1 * 6;
R9 = RC + R1 * 8;
printf("%D:%d%d%d%d\n",RB,R0,R0,R0,R0); //Print the current string
}
else printf("%04X\n", RF); //Print FFFF when it's an incorrct Value
goto L0; //init;
L3: //end
return 0;
}
Új hozzászólás Aktív témák
Hirdetés
● olvasd el a téma összefoglalót!
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Apple iPhone 12 Mini 256GB Kártyafüggetlen, fekete színben, 3 hónap garanciával
- Új Acer Predator 16 WQXGA 165Hz G-Sync i9-13900HX 16GB 1TB Nvidia RTX 4070 8GB 140W Win11 Garancia
- Számítógép, ryzen 5 2600, RX 580 8GB, 16gb ddr4, 512gb ssd, 1tb hdd
- HP EliteBook 850 G8 Fémházas Multimédiás Laptop 15,6" -65% i7-1185G7 16/512 Iris Xe FHD
- Gigabyte GeForce GTX 1660 Ti OC hibátlan, dobozos, 14 nap személyes garanciával
- Huawei P30 Pro 128GB, Kártyafüggetlen, 1 Év Garanciával
- DELL Universal Dock D6000 docking station (452-BCYH) (DisplayLink)
- Felturbóznád a gèped? Ezt Neked ajánljuk!
- Bomba ár! Lenovo IdeaPad V130-15IKB: i5-8G I 8GB I 256SSD I 15,6" FHD I Cam I W11 I Garancia!
- HP ZBook 15 G6 i7-9850H 16GB RAM 512GB SSD NVIDIA Quadro T2000 15.6 FHD 1 év garancia
Állásajánlatok
Cég: FOTC
Város: Budapest