Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the difference between these two forms of inline assembler in C?
    primarykey
    data
    text
    <p>Background: I've been tasked with writing a data collection program for a <a href="http://www.ute.com/product_info.php?id=29" rel="noreferrer">Unitech HT630</a>, which runs a proprietary DOS operating system that can run executables compiled for 16-bit MS DOS, albeit with some restrictions. I'm using the Digital Mars C/C++ compiler, which seems to be working very well.</p> <p>For some things I can use standard C libraries, but other things like drawing on the screen of the unit require assembly code. The assembly examples given in the device's documentation are different from how I was taught to use inline assembly code in C/C++. For reference, <code>BYTE</code> in the examples below is of type <code>unsigned char</code>.</p> <p>Sample of the example code I was given:</p> <pre><code>#include &lt;dos.h&gt; /* Set the state of a pixel */ void LCD_setpixel(BYTE x, BYTE y, BYTE status) { if(status &gt; 1 || x &gt; 63 || y &gt; 127) { /* out of range, return */ return; } /* good data, set the pixel */ union REGS regs; regs.h.ah = 0x41; regs.h.al = status; regs.h.dh = x; regs.h.dl = y; int86(0x10, &amp;regs, &amp;regs); } </code></pre> <p>How I was always taught to use inline assembly:</p> <pre><code>/* Set the state of a pixel */ void LCD_setpixel(BYTE x, BYTE y, BYTE status) { if(status &gt; 1 || x &gt; 63 || y &gt; 127) { /* out of range, return */ return; } /* good data, set the pixel */ asm { mov AH, 41H mov AL, status mov DH, x mov DL, y int 10H } } </code></pre> <p>Both forms seem to work, I haven't encountered a problem with either approach as of yet. Is one form considered better than the other for DOS programming? Does the <code>int86</code> function handle something for me that I am not handling myself in my own assembly code in the second example?</p> <p>Thank you in advance for any help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload