Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:40:34+00:00 2026-06-12T22:40:34+00:00

I’ve recently been developing some embedded software in C for a microcontroller, which only

  • 0

I’ve recently been developing some embedded software in C for a microcontroller, which only has 2kB of Flash memory. Coming to the end of programming, I’ve been hitting the code limit. Up until now, I’ve been increasing the level of compiler optimisation when this happens, retesting and then carrying on happily. However, I recently reached the limit of optimisation and with the addition of the last bit of functionality, ran out of memory again. As a result, I had to get the George Foreman out on my source code and drain some fat.

I messed around with reducing some layers of abstraction here and there, which helped matters slightly but not enough. The next thing I saw was that I had the function prototype

void process_event(Event event, void *data);

which takes as its parameters the event to process and a void pointer that can be used to pass additional data to the call. If I didn’t need any extra data, I passed NULL. This function was written very early on in the development and I realised that I never used data, so I factored it out. This one change gave me the compiled code size saving I needed (~100 bytes), and I’m wondering why, especially considering I generally passed NULL when process_event was called?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:40:37+00:00Added an answer on June 12, 2026 at 10:40 pm

    About 100 bytes would probably be in line with the fact that your call site has to pass an extra argument every time the function is called – this will at least involve a clear of a register, and, depending on your chip, storing it on the stack before the call.

    It is also possible that this simple reduction of one instruction per call could result in more code being removed, depending exactly on how jumps are implemented, as you might find that some code is now in the range of a jump instruction using a short relative offset rather than a long one. A similar saving could be made when trying to load up constants.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.