- 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.
This works, but it’s not nearly as cycle-efficient as using one of Padauk’s handy macros:
When the compiler encounters these macros, it does a source-level replacement of “i” in the content of the block with each value — copying-and-pasting the entire block.
Царский анролл
Why? Because your MCU does not have the ability to do indirect addressing with offsets (constant or otherwise). The compiler wants you to tell it precisely what you want to do. Maybe you want to do this:
Or maybe this:
Both of these have trade-offs.
Именно поэтому я за ассемблер
Если так беспокоит предварительная оптимизация, то можно хинт высрать по этому поводу.
Та херня, которая описывается в той статье https://jaycarlson.net/2019/09/06/whats-up-with-these-3-cent-microcontrollers/ это вообще не Си, а какая-то ебанутай поебень, похожая чем-то на Си. Там например даже цикла for нет
Ахах!
ПОРА УЕЖАТ
В СССР власть считала, что антисоветчиком может быть либо шпион либо безумец. Поскольку не может же нормальный советский человек быть против советской власти и не понимать, что учение Маркса всесильно, потому что оно верно.
В путинской России нет никакой идеологии как внятного образа будущего, но есть идея, что "Россия – это Путин, а Путин – это Россия". Поэтому в 20-му году своего существования путинизм пришел к старой советской формуле: кто против Путина, тот либо на госдеп работает, либо с ума сошел.
Кстати, есть слух, что пригожин сдох
https://censoru.net/uploads/posts/2019-10/1570996995_44bed50be1a79a12e5a98570a56ad c14.jpg
не отвечай ему
> I noticed that Padauk’s “Mini C” compiler didn’t support function arguments, return values, for() loops, and many other common C expressions, I became really nervous
Хах, причем еще и проприетарное.
В общем, finicky to implement
Открытие дороги после ремонта в Уд-Муртии. Хуйло, сало, 2019.