Ú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
● olvasd el a téma összefoglalót!
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Honor 200 Pro - mobilportré
- Szenzorosan védett 12V-2x6 kábel jött az ASRock berkeiből
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- Kerékpárosok, bringások ide!
- YouTube
- PlayStation 5
- Robogó, kismotor
- Luck Dragon: Asszociációs játék. :)
- sziku69: Fűzzük össze a szavakat :)
- Minden, ami hőszivattyú
- További aktív témák...
- Crucial P310 2TB M.2 2230 NVME PCI-E 4.0 x4 - Új - 7100-6000 MBs - Eladó!
- Apple Watch Series 8 45mm GPS
- Crucial P310 1TB M.2 2230 NVME PCI-E 4.0 x4 - Új, bontatlan - 7100-6000 MBs - Eladó!
- Dell 5580 i5-7200u / 8gb ddr4 / 250gb m.2 ssd / jó akku / töltő
- AMD Ryzen 5 7600X BOX - Új, 3 év garancia - Eladó!
- MacBook, Apple M1 / M2 kompatibilis dokkolók, DisplayLink 4K, USB-C, Type-C
- Fotó állvány eladó
- GYÖNYÖRŰ iPhone 12 Pro 256GB Graphite -1 ÉV GARANCIA - Kártyafüggetlen, MS3281, 100% akkumulátor
- Telefon felvásárlás!! iPhone 16/iPhone 16 Plus/iPhone 16 Pro/iPhone 16 Pro Max
- Telefon felvásárlás!! Apple Watch SE/Apple Watch SE 2 (2022)
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft.
Város: Budapest
Cég: FOTC
Város: Budapest