I'm working on a Chip-8 emulator in C with the goal of having it be as cross platform and as small as possible for compatibility with embedded systems and systems with low specs (and to challenge myself), which means being able to use SDL, ncurses (when I get to that point) and something else as well. As such, I've been using unsigned chars in place of ints or unsigned ints, and I used "typedef unsigned char byte" to make it more convenient. Am I wasting my time, even with the goal of ideally making it compatible with very small systems, or would just using "typedef unsigned int byte" be enough without sacrificing performance?
Usefulness of unsigned char in on embedded systems in C
537 Views Asked by eggbertx At
2
There are 2 best solutions below
2
Lundin
On
You've got the basic idea right, but not the solution. In modern C, we have the uint_fast8_t type in stdint.h.
This is the type you should use, meaning that you are telling the compiler: "I don't need more than 8 bytes for this integer, but feel free to use a larger size if that improves performance."
Related Questions in C
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in RESOURCES
- Impala Resource Estimation for queries with Group by
- angular load more tweets onclick
- jar file input == null while java app is working
- Java: Accessing resources and the Law Of Demeter
- rails 4 article data template
- Overriding string resources from module/library that have translations in Android
- Service worker does not load mp3 files
- REST: not all representations immediately available
- Richfaces custom skinning images
- How to make Puppet track TCP ports to avoid conflicts?
- Which channel type uses the least amount of memory in Go?
- Make a Button resource and use it in multiple places
- Connecting Rails backend with Angular frontend
- creating unique onClick listener for each item in a carousel - Android / Java
- Date format angular $resource
Related Questions in EMBEDDED
- PHP don't use temp file for upload
- Sparkfun SC16IS750 does not work on Raspberry Pi
- Reserve memory space in m_text memory region of FLASH on embedded target
- SAE J1939 Standards Collection -- How much is necessary?
- How to call multiple slaves for Spi data transmission?
- Deployment over GPRS to embedded devices
- Changing just one byte in SD card sector
- Comparion of values won't work without delay
- Better to pass struct, or pointer to struct?
- STM32F4 Handling peripheral error while making a DMA Transfer (RX)
- USB programming, transfer file from iOS device to Embedded os device?
- using Diab, dcc 5.9.4 to compile a windows executable
- does b64_pton() work if input contains special characters? I am using it in C code
- u-boot select boot partition based on GPIO state
- Why is a write to a memory-mapped peripheral register not actioned (LPC43xx)?
Related Questions in MEMORY-FOOTPRINT
- Get the current memory usage of a variable?
- Program memory footprint for different interpreters/compilers
- Proper Android Activity Cleanup to Reduce Memory Footprint
- Reduce memory footprint in the construction of a BigInt class
- Making C#/.NET have a small footprint?
- Speed and Memory managment of C vs Perl
- Calculation of memory footprint
- Retrieve memory usage and CPU usage from jvm
- Eclipse IDE High Memory Footprint
- Laravel Queue Worker Memory Footprint is Too Big :/
- Windows 8 Store App - Memory footprint too high
- I need to find the object quickly while using as little memory as possible. What data container should I use?
- docker-compose with similar images
- Usefulness of unsigned char in on embedded systems in C
- RDD Memory footprint in spark
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You should just separate the interpreter from the io bindings.
Only the interpreter needs to be 8 bits portable.
Each target platforms will have a different set of technologies available for IO.
SDL or curses will give you some sort of portability between *nix and windows platforms but if available, you'll probably have 32bits integers, maybe have to deal with 16 bits. But surely not with 8 bit integers.
On the other hand, dealing with 8 bits and 16 bits bare metal processors, means you'll probably just hook your project directly to the graphic driver.