User Tools

Site Tools


blog:pushbx:2023:0320_multiplexer_checks_ldebug_changes_to_iocline_and_getinput_fixes_and_highlighting_rebuilding_ia16_gcc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

blog:pushbx:2023:0320_multiplexer_checks_ldebug_changes_to_iocline_and_getinput_fixes_and_highlighting_rebuilding_ia16_gcc [2023-03-20 20:43:49 +0100 Mar Mon] (current)
ecm created
Line 1: Line 1:
 +====== Multiplexer checks, lDebug changes to IOCLINE and getinput fixes and highlighting, rebuilding IA16 gcc ======
 +
 +**2023-03-19**
 +
 +This week several developments occurred.
 +
 +===== TSR AMIS multiplexer detection changes =====
 +
 +[[https://hg.pushbx.org/ecm/tsr/shortlog/a1388b2f7501|These changes]], which are only done for the TSR example as yet but can be ported to the other TSRs (RxANSI, lClock, SEEKEXT, KEEPHOOK, TESTALOC), concern the detection of a debugger as well as a resident instance of the application. It's important to optimise these because in the common case, nearly 256 multiplex numbers need to be checked. [[blog:pushbx:2023:0320_ldebug_release_5_goofs_control-c_and_planned_new_tsr_j_switches|Tracing lClock on the HP 95LX]] took very long because of these loops.
 +
 +First I cut down on the number of instructions running per check. I [[https://hg.pushbx.org/ecm/tsr/rev/992984a4d14e|inlined the debugger check]] to avoid the overhead of a call. For the resident instance check, I [[https://hg.pushbx.org/ecm/tsr/rev/acde3c2e9afd|changed the call protocol of the check function]] so it won't return on finding an instance, cutting down on the signalling and the conditional branches after the calls. (Inlining this check is not possible because the ''/X='' number needs to be checked before running the loop from 0FFh to 00h, in case it is set.)
 +
 +Next, I [[https://hg.pushbx.org/ecm/tsr/rev/1d157a61d8a9|changed the ''.loopplex'' loop]] in the interrupt unhook handler so as to push and pop ''cx'' once each, rather than for every multiplex number.
 +
 +Finally, I [[https://hg.pushbx.org/ecm/tsr/rev/a1388b2f7501|re-arranged things so that there is only a single loop]] which checks for both the debugger and the resident instance, calling the AMIS installation check only once per multiplex number. If one of the two is found, the loop continues to search only for the other. If the other is subsequently found as well, then the loop is aborted. This nearly halves the number of instructions in the worst case and adds about 20 instructions in the best case (if the debugger and the resident instance are both immediately found).
 +
 +There is a slight behaviour change: If an ''/X='' number is specified then this first check will now also check for the debugger. This is considered acceptable.
 +
 +
 +===== lDebug changes =====
 +
 +First I extracted most of the ''IOCLINE'' logic [[https://hg.pushbx.org/ecm/ldebug/rev/6b242edd13e0|into three separate functions]] to make it usable for other callers. The first such caller is the ''Rx.LIST'' command. It [[https://hg.pushbx.org/ecm/ldebug/rev/e17c10f23282|was first converted to buffer data]] in the ''line_out'' buffer, flushing this buffer if it gets too full or at the very end. Then [[https://hg.pushbx.org/ecm/ldebug/rev/4977ba9d25e9|it was changed to use the new functions]].
 +
 +Next, the original ''IOCLINE'' logic was [[https://hg.pushbx.org/ecm/ldebug/rev/a761885d96c3|replaced by three function calls]] to the new functions, significantly cleaning up this bit and making it easier to grasp. This was helped a lot by how generic the new functions turned out to be, almost completely eliminating the special-casing of the prompt string followed by the input string. I think it's a big win for readability.
 +
 +The next changes were done in the function formerly known as ''rawinput'', [[https://hg.pushbx.org/ecm/ldebug/rev/86e5a5fc3229|now renamed ''getinput'']]. These changes were [[https://hg.pushbx.org/ecm/tractest/shortlog/e1db79722b1f|ported from lDebug back to the ''getinput'' function of TracList]], which is written in perl. The TracList application [[https://hg.pushbx.org/ecm/tractest/file/708f9d364c6b/traclist.pl#l390|originated the more complex ''getinput'' logic]] which redraws within a single row to allow entering and editing lines longer than would fit in the amount of columns per line.
 +
 +The changes include several bugfixes for very narrow display columns, such as comparing the ''col'' variable to ''maxpercol'' when [[https://hg.pushbx.org/ecm/ldebug/rev/413496820e70|it should be compared to the sum]] of ''maxpercol'' and ''promptlength''. The next fix was [[https://hg.pushbx.org/ecm/ldebug/rev/c4988c841ea4|forcing ''maxpercolhalf'' to 1]] if it was calculated as 0, avoiding an infinite loop.
 +
 +The final fix concerns handling of narrow lines as well; in the test case there is a ''maxpercol'' of 5 and thus ''maxpercolhalf'' of 2. When entering the string ";456789abcdef" then scrolling back using the Left Arrow key, the letter "a" will not become visible. This was [[https://hg.pushbx.org/ecm/ldebug/rev/2c3c95d3caa0|fixed by checking if scrolling back results]] in a cursor column (''col'') at the very end of the visible window, and there would be an invisible text codepoint just off the visible part (ie, we aren't displaying the very end of the input already).
 +
 +The next change is simply to [[https://hg.pushbx.org/ecm/ldebug/rev/15d84725ca63|make the register change highlighting conditional]] on a build time option. This was in preparation to a new option which [[https://hg.pushbx.org/ecm/ldebug/rev/9d7f1b9dad5f|highlights the first]] and [[https://hg.pushbx.org/ecm/ldebug/rev/4abf22cf7a66|last visible text]] codepoint of the ''getinput'' line if there is more (currently invisible) text past the first/last text.
 +
 +Finally, some optimisations were made, one of which is somewhat important for Einsicht: If a text codepoint is appended to the input line without scrolling the visible text, then [[https://hg.pushbx.org/ecm/ldebug/rev/b120bf22afe2|only the appended text is displayed in place]] now. This avoids the prior behaviour of redrawing the entire prompt and input so far for every appended codepoint. The other optimisation concerns handling of the Left Arrow and Right Arrow keys; if they result in the cursor scrolling without scrolling the visible input text, then [[https://hg.pushbx.org/ecm/ldebug/rev/bced1d493380|only the text in front of the desired cursor position]] is redrawn. Previously this would redraw the entire visible text **and** then also the text in front of the target cursor position. (Idea: If we are scrolling the cursor to the right then it may suffice to display only a single codepoint. This may require highlighting if the cursor was in the very left-most visible spot.)
 +
 +Both of these optimisations mandated moving the first redraw of the prompt later into the ''getinput'' redraw handler, just before the full input text is redrawn. This is to make it conditional on the append and cursor move conditions both being false. The conditions are, in turn, both forced to false in case the ''lastskip'' value does not match the new ''skip'' variable (held in register ''di''). So the conditions must be checked, to avoid the prompt redraw, after the final value of ''skip'' has been determined.
 +
 +A small optimisation [[https://hg.pushbx.org/ecm/ldebug/rev/58253fe5e484|changes the boolean variables]], stored one per byte, in ''getinput'' to use -1 as the true value. This allows to check them using ''rol'' and invert them using ''not'', for shorter instruction encodings. This optimisation is gleaned from shsucdx. A related optimisation is [[https://hg.pushbx.org/ecm/ldebug/rev/350bc24300a8|to share code pathes]] that set a single flag before jumping back to the main processing loop.
 +
 +
 +===== Rebuilding the IA16 gcc toolchain =====
 +
 +Today I noted that andrewbird suggested [[https://github.com/FDOS/share/pull/18|a Pull Request to FreeDOS SHARE]] that is said to require a bugfix in the toolchain. To avoid a broken build of my automatic daily builds, if this PR is merged, I went and rebuilt the toolchain on our servers. I found three defects during that:
 +
 +  * An i386 libc development package [[https://github.com/tkchia/build-ia16/issues/22|must be installed on the amd64 host]] to build JWlink.
 +  * My older dosemu2 build from 2019 combined with a current FreeCOM failed to correctly run the ''-E exit'' command passed to it by the libi86 test suite to check for COM4 support, resulting in a hang.
 +  * The binutils-djgpp step of the build [[https://github.com/tkchia/build-ia16/issues/23|failed on a missing function]].
 +
 +Also, some of the libi86 tests failed, but I was able to ignore that by running ''(cd build-libi86 && make install)'' to force installation.
 +
 +Another problem was the server storage space, which is close to filling the 212 GB allocated to it.
 +
 +{{tag>tsr ldebug traclist gcc}}
 +
 +
 +~~DISCUSSION~~
  
blog/pushbx/2023/0320_multiplexer_checks_ldebug_changes_to_iocline_and_getinput_fixes_and_highlighting_rebuilding_ia16_gcc.txt ยท Last modified: 2023-03-20 20:43:49 +0100 Mar Mon by ecm