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
540 views Asked by eggbertx At
2
There are 2 answers
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
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in RESOURCES
- need help solving this resource allocation problem
- How can I know if spark application/job is idle/waiting for resources?
- Why the strings of Resources contain garbage prefixes different sizes and how to trim it?
- Reading version from resource file dll project
- Azure resource creation issue - "The subscription is not allowed to create or update the serverfarm"
- Some users facing issues changing app language in Android app
- C#: Cannot access Resources dictionary only from MainWindow.xaml.cs file
- Cloning resources group into another
- REST APIs to demonstrate borrowed books and users from library
- Problem while deploying Aks using terraform in Azure
- Visual Studio is not re-generating Resources class anymore
- Can't find any new guides and documentation on WPF localization
- visual studio c# - dynamic insertion of images via reference
- Problem with loading resource Files in JavaFX
- How to give shape to view in adnroid
Related Questions in EMBEDDED
- MSP430F5529 on the MSPEXP430F5529LP: UART is not actually transmitting despite seemingly correct setup. What is wrong?
- A FPGA Project Proposal where I can use both PS and PL
- Program doesn't run after DFU
- Sending struct through queue
- How to generate a VPI warpmap for polynomial distortion correction?
- How to present this example concept in UML: Using 2 LCD displays in C/C++
- CLion: Debug via St-Link
- Portenta H7 Baremetal Development and a Little Guidance on Embedded System Learning Roadmap
- STM32 RTC3 Mixed Mode: Writing TR resets SSR
- Unable to read value from gpio set as input
- Mbed TLS: in-place en-/decryption for OAEP doesn't seem to work
- Shared variable read from low priority thread in preemptive scheduling
- Own Pattern / framework for interfacing with components in C
- Performance Difference Between Global Variable and Local Variable in Embedded Systems
- Comparing analog signal from Electret mic with samples
Related Questions in MEMORY-FOOTPRINT
- Memory Leak? Chrome's 'Memory Footprint' in the Task Manager is rising, despite 'JavaScript Memory' and 'GPU Memory' being stable
- ASP.Net Core 2.1 Memory consumption window s10 and windows server
- How do I destroy the KonvaJs animation from the memory footprint?
- Why react application using more memory footprint?
- Why java has a huge memory footprint in docker container
- Can we recover a frame from a paint.exe process dump
- Java object memory footprint - what to believe ? jhat ? ClassLayout?
- Speed and Memory managment of C vs Perl
- Memory-footprint combobox (search autocomplete)
- Can programs use (significantly) less memory when compiled for different processors?
- How to use bit instead of bool in golang structure?
- Big memory footprint of domNode document representation
- What is the best way to gain insights in the memory footprint & usage of a native image that runs inside a dockercontainer?
- Do Java Records actually save memory over a similar class declaration or are they more like syntactic sugar?
- Memory Footprint calculation of a java list and GC calculation
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?
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)
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.