low-level

TIB Custom Storage

别来无恙 提交于 2019-12-10 11:28:59
问题 After quite a bit of googling and some hints given here, I finally managed to find a layout of the FS segment (used by windows to store TIB data). Of particular interest to me is the ArbitraryUserPointer member provided in the PSDK: typedef struct _NT_TIB { struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList; PVOID StackBase; PVOID StackLimit; PVOID SubSystemTib; union { PVOID FiberData; DWORD Version; }; PVOID ArbitraryUserPointer; struct _NT_TIB *Self; } NT_TIB; How safe exactly is it to

Compiler-Programming: What are the most fundamental ingredients?

☆樱花仙子☆ 提交于 2019-12-09 11:50:59
问题 I am interested in writing a very minimalistic compiler. I want to write a small piece of software (in C/C++) that fulfills the following criteria: output in ELF format (*nix) input is a single textfile C-like grammar and syntax no linker no preprocessor very small (max. 1-2 KLOC) Language features: native data types: char, int and floats arrays (for all native data types) variables control structures (if-else) functions loops (would be nice) simple algebra (div, add, sub, mul, boolean

Computing 8 horizontal sums of eight AVX single-precision floating-point vectors

大城市里の小女人 提交于 2019-12-08 17:43:34
问题 I have 8 AVX vectors containing 8 floats each (64 floats in total) and I want to sum elements in each vector together (basically perform eight horizontal sums). For now, I'm using the following code: __m256 HorizontalSums(__m256 v0, __m256 v1, __m256 v2, __m256 v3, __m256 v4, __m256 v5, __m256 v6, __m256 v7) { // transpose const __m256 t0 = _mm256_unpacklo_ps(v0, v1); const __m256 t1 = _mm256_unpackhi_ps(v0, v1); const __m256 t2 = _mm256_unpacklo_ps(v2, v3); const __m256 t3 = _mm256_unpackhi

Why is a function call, rather than variable addresses, used to detect stack growth direction?

醉酒当歌 提交于 2019-12-08 16:43:54
问题 I read different responses to the question of detecting stack growth detection and I understand that, in modern architectures, stack might grow randomly, might be created off heap, and so on. However, in this classic interview question, I want to understand why people use a function call rather than comparing 2 local variables in the same function. I think there must be some particular reason for doing this but, not being a C/low level developer [Java :)], I am simply guessing. Here is the

Are there any use cases relying on integer representation of two allocations being different in C?

荒凉一梦 提交于 2019-12-08 15:19:12
问题 For example, consider the following C code snippet: void *p = malloc(1); void *q = malloc(1); bool question = (uintptr_t) p == (uintptr_t) q; I expect everyone expects question be always false. (Surprisingly, the C11 standard does not require it, though. The only restriction on uintptr_t is e.g. ((void *) ((uintptr_t) p)) == p . See 7.20.1.4 of the C11 standard for details.) My question is: is there any realistic use case that actually relies on the guarantee that question be false, or more

How do computers differentiate 2 pieces of data? [closed]

一世执手 提交于 2019-12-08 02:45:07
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . I was wondering that computers store all the info in the form of 1s and 0s/low and high voltage, yada yada...but then when we compile the program, it - or just any data stored on the comp - is in binary form...then how does the computer differentiate between 2 pieces of data, since all it consists is a stream of

Is it worth to implement small filesystem for an EEPROM

血红的双手。 提交于 2019-12-07 06:09:11
问题 I have bought an I2C EEPROM. I want to store sensor and voltage data. I'm assuming that value can be bigger than one byte, and there can be a lot of data. Is it worth is such case to implement a filesystem with small file allocation table? It would make me easier to peek trought EEPROM for example. 回答1: I see two causes for a FAT on EEPROM If there is a requirement for the flexibility of having different files. Such as for data logging or configurations. It allows multiple such configuration

Bluetooth protocol over wifi?

陌路散爱 提交于 2019-12-07 02:21:49
问题 I'm looking to implement the Bluetooth protocol over a physical Wi-Fi based transport, if that makes sense. Basically my phone has Bluetooth, and my laptop has a Wi-Fi card (802.11a/b/g). I know that Wi-Fi operates over the range 2.412 GHz - 2.472 GHz, and that Bluetooth operates over the range 2.402 GHz - 2.480 GHz. I couldn't help but notice the overlap here. So my questions are: What sort of low-level APIs would I need (preferably in C, on Windows) in order to send a signal out at certain

How to enable ARMv6 unaligned access on WinMobile6?

匆匆过客 提交于 2019-12-06 16:53:52
ARMv6 introduce a great feature - unaligned memory access , which make some things in code much more simplier and faster. But microsoft gives API for it only in winCE6. And most PDAs now based on WinMobile6 (which is on CE 5.x). And unaligned access is disabled by default :( I've try to set unaligned flag in CP15 register, but this doesn't work - I have a crash on read unaligned data. Is it possible to enable unaligned access on WinMobile6? Edit: I've found the tool, which can enable unaligned access, but I want to on/off it from my code. It's nueAdvancedProcessor . There is an unaligned

TIB Custom Storage

荒凉一梦 提交于 2019-12-06 16:01:13
After quite a bit of googling and some hints given here , I finally managed to find a layout of the FS segment (used by windows to store TIB data). Of particular interest to me is the ArbitraryUserPointer member provided in the PSDK: typedef struct _NT_TIB { struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList; PVOID StackBase; PVOID StackLimit; PVOID SubSystemTib; union { PVOID FiberData; DWORD Version; }; PVOID ArbitraryUserPointer; struct _NT_TIB *Self; } NT_TIB; How safe exactly is it to use this variable (under Vista and above)? and does it still exist on x64? Secondary to that is the