[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Simple C / asm help

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 10
Thread images: 1

File: shutterstock-programming.jpg (1012KB, 3888x2592px) Image search: [Google]
shutterstock-programming.jpg
1012KB, 3888x2592px
I essentially have to translate this into asm

"
 
cDoMath(const int8_t *a, const int16_t *b, int32_t *c, int max, int offset) {
for (int i = 0; i < max; i++) {
c[i] = a[i] * b[i] - offset;
}
}
"

what I don't understand is

" c[i] = a[i] * b[i] - offset; "

I know offset is the address of the symbol but what does the c[i] mean
Explain to a retard please. I don't know C
>>
>>60116173
mov ebx, [b+i]
mov eax, [a+i]
mul ebx
sub eax, [offset]
mov [c+i], eax

something like that
>>
>>60116173
These are presumably pointers to arrays of size "max", so you can iterate through them. the [ ] is an access operator, c[0] being the first element of the c array.
>>
Sorry I fucked up on format.
>>
>>60116210
>>60116202

Ahhh okay got it, yes max is an array I cant believe I overlooked that. thank you for that!
>>
>>60116173
Fun fact. You can use
gcc -S MyFile.c
to generate assembly code.
>>
>>60116919
you mean
>gcc -masm=intel -S MyFile.c
>>
>>60116973
Well I prefere intel syntex from AT&T but both commands will generate assembly code.
>>
>>60116919
it's not the most readable output though
>>
>>60117124
Or just compile and use objdump, I suppose.
Thread posts: 10
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.