<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 497: mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/</link><description>Recent changes to 497: mcs51 usim: pass return value of simulated main function to host</description><atom:link href="https://sourceforge.net/p/sdcc/patches/497/feed.rss" rel="self"/><language>en</language><lastBuildDate>Mon, 06 Apr 2026 03:26:07 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/sdcc/patches/497/feed.rss" rel="self" type="application/rss+xml"/><item><title>#497 mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/?limit=25#c99b</link><description>&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;What about using a label on the seljump which is after main?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Please see the attached patch.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Oleg Endo</dc:creator><pubDate>Mon, 06 Apr 2026 03:26:07 -0000</pubDate><guid>https://sourceforge.net84c38e1e3d595bf19d5eda604603de51dae82a1a</guid></item><item><title>#497 mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/?limit=25#a73d</link><description>&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;What about using a label on the seljump which is after main?&lt;br/&gt;
uCsim can get address of the label from the cdb (or map) file and automatically break at that address and pass out return value produced by sim_stop_result().&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Yes, that sounds good!&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Oleg Endo</dc:creator><pubDate>Sun, 05 Apr 2026 14:51:59 -0000</pubDate><guid>https://sourceforge.net5fcabd86f66f5a57478183970be5c52e11fe0891</guid></item><item><title>#497 mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/?limit=25#8a56/5055</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks!&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Oleg Endo</dc:creator><pubDate>Sun, 05 Apr 2026 14:38:47 -0000</pubDate><guid>https://sourceforge.netbad5e3ef5e80b8f9a8320405fd375a99b7185904</guid></item><item><title>#497 mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/?limit=25#8a56</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;a class="alink" href="/p/sdcc/code/16444/"&gt;[r16444]&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel Drotos</dc:creator><pubDate>Sun, 05 Apr 2026 14:13:30 -0000</pubDate><guid>https://sourceforge.net3a88f3b40090285538cf2b43c2c2894353714b6a</guid></item><item><title>#497 mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/?limit=25#6a9b</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;What about using a label on the seljump which is after main?&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;__sdcc_program_startup&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;lcall&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;_main&lt;/span&gt;
&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;main&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;will&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;lock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;up&lt;/span&gt;
&lt;span class="nt"&gt;__magic_point_after_main_to_stop_on&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;sjmp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;uCsim can get address of the label from the cdb (or map) file and automatically break at that address and pass out return value produced by sim_stop_result().&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel Drotos</dc:creator><pubDate>Sun, 05 Apr 2026 14:02:11 -0000</pubDate><guid>https://sourceforge.nete5e542da302d7753a5b6c96d9d162ec2c4f84e41</guid></item><item><title>#497 mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/?limit=25#68b5</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks for looking into it.  &lt;/p&gt;
&lt;p&gt;I've been trying to update my SDCC from 4.2 to 4.5 and had this patch has been sitting in my tree. Apparently using selfjump was the old way of doing it.  In fact, it's even still described in the 4.5 manual:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c"&gt;(main&lt;/span&gt;&lt;span class="nt"&gt;.&lt;/span&gt;&lt;span class="c"&gt;asm)&lt;/span&gt;
&lt;span class="c"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;.&lt;/span&gt;&lt;span class="c"&gt;area GSFINAL (CODE)&lt;/span&gt;
&lt;span class="c"&gt;    ljmp __sdcc_program_startup&lt;/span&gt;
&lt;span class="c"&gt;;&lt;/span&gt;&lt;span class="nb"&gt;--------------------------------------------------------&lt;/span&gt;
&lt;span class="c"&gt;; Home&lt;/span&gt;
&lt;span class="c"&gt;;&lt;/span&gt;&lt;span class="nb"&gt;--------------------------------------------------------&lt;/span&gt;
&lt;span class="c"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;.&lt;/span&gt;&lt;span class="c"&gt;area HOME (CODE)&lt;/span&gt;
&lt;span class="c"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;.&lt;/span&gt;&lt;span class="c"&gt;area CSEG (CODE)&lt;/span&gt;
&lt;span class="c"&gt;__sdcc_program_startup:&lt;/span&gt;
&lt;span class="c"&gt;    lcall _main&lt;/span&gt;
&lt;span class="c"&gt;; return from main will lock up&lt;/span&gt;
&lt;span class="c"&gt;    sjmp &lt;/span&gt;&lt;span class="nt"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;It's just that the documentation doesn't match the actual implementation.&lt;/p&gt;
&lt;p&gt;I've also tried using simif 's' command and the execution path is different of course and the return value not forward. So I'm attaching another patch to fix this. It's adding a new function &lt;code&gt;cl_uc::sim_stop_result&lt;/code&gt;.  Please have a look again.&lt;/p&gt;
&lt;p&gt;By trying very hard, it seems the main function can be tricked into returning to a controlled exit function by overriding &lt;code&gt;__sdcc_external_startup&lt;/code&gt;and re-implementing the static initialization.&lt;/p&gt;
&lt;p&gt;But perhaps it's better to add a way to allow users to implement/override their own exit function.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Oleg Endo</dc:creator><pubDate>Sun, 05 Apr 2026 11:33:01 -0000</pubDate><guid>https://sourceforge.netd01c87a93b13259b63fb7cb06a0206d410b27659</guid></item><item><title>#497 mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/?limit=25#9b6b</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;I've applied uCsim part only! Code generator is not touched.&lt;/p&gt;
&lt;p&gt;I think that selfjump after the main is not a good solution, as selfjump detection is not used in mcs51 regtests, becouse it is valid in normal code.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel Drotos</dc:creator><pubDate>Sat, 04 Apr 2026 16:30:20 -0000</pubDate><guid>https://sourceforge.net41bd3d48f9df4a13c7d1d1922dace8b2191f7648</guid></item><item><title>#497 mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/?limit=25#97ca</link><description>&lt;div class="markdown_content"&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;: open --&amp;gt; closed-accepted&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;assigned_to&lt;/strong&gt;: Daniel Drotos&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Group&lt;/strong&gt;:  --&amp;gt; &lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel Drotos</dc:creator><pubDate>Sat, 04 Apr 2026 16:23:41 -0000</pubDate><guid>https://sourceforge.netb04fe0ff0c08f9a012bae6e6c68a1ea3883a5495</guid></item><item><title>mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;When running a program in the mcs51 simulator the return value of that program is lost (hardcoded to 0). This makes it difficult to use for running tests on the host and catching &lt;code&gt;EXIT_SUCCESS/ EXIT_FAILURE&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The attached patch allows the return value to be passed through.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Oleg Endo</dc:creator><pubDate>Sat, 04 Apr 2026 13:18:04 -0000</pubDate><guid>https://sourceforge.net0dc387b793337650d637fc7f68740a692066ec00</guid></item><item><title>mcs51 usim: pass return value of simulated main function to host</title><link>https://sourceforge.net/p/sdcc/patches/497/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Ticket 497 has been modified: mcs51 usim: pass return value of simulated main function to host&lt;br/&gt;
Edited By: Daniel Drotos (drdani)&lt;br/&gt;
Status updated: 'open' =&amp;gt; 'closed-accepted'&lt;br/&gt;
Owner updated: None =&amp;gt; 'drdani'&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Oleg Endo</dc:creator><pubDate>Sat, 04 Apr 2026 13:18:04 -0000</pubDate><guid>https://sourceforge.neta82a0a54fdc3d122733b6c1ffe11bb78439a0e48</guid></item></channel></rss>