-
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
// https://jaycarlson.net/2019/09/06/whats-up-with-these-3-cent-microcontrollers/
// The C code I used for those original MCU tests looked something like this:
volatile int16_t in[25];
volatile int16_t out[25];
const int16_t a0 = 16384;
const int16_t a1 = -32768;
const int16_t a2 = 16384;
const int16_t b1 = -25576;
const int16_t b2 = 10508;
int16_t z1, z2;
int16_t outTemp;
int16_t inTemp;
void main()
{
while(1) {
_pa = 2;
for(i=0;i<25;i++)
{
inTemp = in[i];
outTemp = inTemp * a0 + z1;
z1 = inTemp * a1 + z2 - b1 * outTemp;
z2 = inTemp * a2 - b2 * outTemp;
out[i] = outTemp;
}
_pa = 0;
}
}
// The Padauk code looks like this:
WORD in[11];
WORD out[11];
WORD z1, z2;
WORD pOut, pIn; // these are pointers, but aren't typed as such
int i;
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/2 // SYSCLK=IHRC/2
PAC.6 = 1; // make PA6 an output
while(1) {
PA.6 = 1;
pOut = out;
pIn = in;
i = 0;
do {
*pOut = (*pIn << 14) + z1;
z1 = -(*pIn << 15) + z2
+ (*pOut << 14)
+ (*pOut << 13)
+ (*pOut << 9)
+ (*pOut << 8)
+ (*pOut << 7)
+ (*pOut << 6)
+ (*pOut << 5)
+ (*pOut << 3);
z2 = (*pIn << 14)
- (*pOut << 13)
- (*pOut << 11)
- (*pOut << 8)
- (*pOut << 3)
- (*pOut << 2);
i++;
pOut++;
pIn++;
} while(i < 11);
PA.6 = 0;
}
}
> As for the filter function itself, you’ll see that all the multiplies have been replaced with shift-adds. The Padauk part does not recognize the * operator for multiplication; trying to use it to multiply two variables together results in a syntax error. No, I’m not joking.
j123123,
11 Октября 2019
-
0
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
#include <stdio.h>
#define BIG_ENDIAN 0
#define LITTLE_ENDIAN 1
int TestByteOrder() {
short int word = 0x0001;
char *b = (char *)&word;
return (b[0] ? LITTLE_ENDIAN : BIG_ENDIAN);
}
int main() {
int r = TestByteOrder();
printf("%s\n", r == LITTLE_ENDIAN ? "Little Endian" : "Big Endian");
return r;
}
Игрушечная программа, проверяет порядковость байтов процессора ("endianness"); хотя изначально понятно что WinNT всегда "от младшего к старшему".
Она безупречно правильная, но меня не устраивает ее размер. Ведь всё можно было бы уместить в две строки. (А еще лучше перевести на АСМ). Прошу знатоков поупражняться.
tmayh,
06 Октября 2019
-
0
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
#include <ncurses.h>
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#define msleep(msec) Sleep(msec)
#else
#include <unistd.h>
#define msleep(msec) usleep(msec*1000)
#endif
int main()
{
initscr();
char str[100];
addstr("Enter string: ");
getstr(str); //Считваем строку
curs_set(0); //"Убиваем" курсор, чтобы не мешался
while ( true )
{
//Перемещаем х-координату как можно дальше вправо, и будем уменьшать её, пока она != 0
for ( unsigned x = getmaxx(stdscr); x; x-- )
{
clear();
mvaddstr(getmaxy(stdscr) / 2, x, str);
refresh();
msleep(200);
}
}
endwin();
return 0;
}
https://code-live.ru/post/ncurses-input-output/#getstr-
Сколько хуйни вы можете найти в этом примере?
j123123,
04 Октября 2019
-
0
- 1
https://sun9-4.userapi.com/c855432/v855432603/1011cc/WhUv5xKLMsM.jpg
OlegUP,
24 Сентября 2019
-
−1
- 1
- 2
- 3
- 4
- 5
- 6
- 7
Сначала вот
https://medium.com/@selamie/remove-richard-stallman-fec6ec210794
А потом вот
https://www.fsf.org/news/richard-m-stallman-resigns
ПРЫЩЕБЛЯДИ СОСНУЛИ ОЧЕНЬ СЕРЬЕЗНО
MAPTbIwKA,
17 Сентября 2019
-
0
Ко-кок
http://torvaldsfinger.com/
LinuxGovno,
13 Сентября 2019
-
−2
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
char** explode(char* inaddr, char s)
{
char** xxx;
xxx=(char**)malloc(strlen(inaddr));
char* temp;
temp=(char*)malloc(strlen(inaddr));
int u=0,i=0,t=0;
char* getln(char *addr)
{
while (*(addr+i) !=s && *(addr+i) !='\0' && *(addr+i) !=EOF)
{temp[t]=inaddr[i];t++;i++;};
temp[t]='\0';
i++;t=0;
return(temp);
}
while (inaddr[i])
{
xxx[u]=strdup(getln(inaddr));
u++;
};
return(xxx);
};
//для проверки результата
char* str="Y000:aa;dsf;dddsf;dsfdsf;1YYYYY;YYYYY;YYYYYY;sfd:sfdsfdsfdsfdsfdsfdsfdsf1YYYYYYY:YYYYYYYYY;b;cc;Ydsfds;876786876a:1132";
char** eee;
eee=(char**)malloc(strlen(str));
eee=explode(str, ';');
int zz=0;
while(eee[zz])
{
printf("%s\n",eee[zz] );zz++;
};
printf("%c",eee[0][0] );
printf("\n" );
}
функция explode() как php давно о такой мечтал.
killer1804,
04 Сентября 2019
-
−2
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
//типа explode в php;
{
int i=0;
//char s=';';
char s=argv[2][0];
i=100;
//char** data;
//data=(char**)malloc(i+1);
char data[1000][1000];
char* str;
str=malloc(i+1);
str=argv[1];
printf("%s\n",str );
int n=0;
int m=0;
while (*str) {
if (*str==s)
{m++;n=0;str++;continue;};
data[m][n]=*str;
str++;n++;
};
printf("%s\n",data[0] );
}
Типа explode в php
Кто-нить знает как это заставить работать с
//char** data;
//data=(char**)malloc(i+1);
??
killer1804,
03 Сентября 2019
-
0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xaaaaaaaa);
n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xcccccccc);
n = ((n >> 4) & 0x0f0f0f0f) | ((n << 4) & 0xf0f0f0f0);
n = ((n >> 8) & 0x00ff00ff) | ((n << 8) & 0xff00ff00);
n = ((n >> 16) & 0x0000ffff) | ((n << 16) & 0xffff0000);
-- C code which reverses the bits in a word.
neTyx_npoTKHyTbIu,
03 Сентября 2019
-
−1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char* line;
char* start;
char* dop;
start=(char*)malloc(10000);
dop=(char*)malloc(10000);
start[0]='e';
start[1]='c';
start[2]='h';
start[3]='o';
start[4]=' ';
int i=5;
dop[0]=' ';
dop[1]='|';
dop[2]=' ';
dop[3]=' ';
dop[4]='b';
dop[5]='c';
dop[6]=' ';
dop[7]='-';
dop[8]='l';
line=(char*)malloc(10000);
line=argv[1];
while (*line) {*(start+i)=*line;line++;i++;};
while (*dop){*(start+i)=*dop;dop++;i++;};
system(start);
}
Калькулятор
killer1804,
01 Сентября 2019