masm32 http://www.e-learn.cn/tag/masm32 zh-hans Can't output coprocessor float from variable two times in a row http://www.e-learn.cn/topic/4040596 <span>Can&#039;t output coprocessor float from variable two times in a row</span> <span><span lang="" about="/user/47" typeof="schema:Person" property="schema:name" datatype="">谁说胖子不能爱</span></span> <span>2021-01-29 14:35:55</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>Good afternoon! In this example, I simply add two numbers with a comma, save the variable in <strong>tbyte</strong> and display the same variable two times in a row on the screen, but the first time I get <strong>11.1</strong>, as it should be, and the second time <strong>4.667261E-062</strong>. Why is this happening?</p> <p>And one more question, is it possible in <strong>tbyte</strong> to somehow save and access numbers by array type? for example, storing numbers in <strong>dd</strong>, I just could save and read them in increments of 4, for example, <code>result [0]</code>, <code>result [4]</code>, etc. Is it possible to use the same with <strong>tbyte</strong> and how? If I understand right - it should be a step of <strong>10</strong>.</p> <pre><code>.386 .model flat,stdcall option casemap:none include \masm32\include\masm32rt.inc .data titletext db 'Title',0 frmt db 'Result1 = %.7G',10 db 'Result2 = %.7G',0 buff db 1024 dup (?) result tbyte ? num1 qword 5.5 num2 qword 5.6 .code start: finit fld qword ptr [num1] fld qword ptr [num2] fadd fstp qword ptr [result] invoke crt_sprintf,addr buff,addr frmt, result, result invoke MessageBox,0,addr buff,addr titletext,MB_OK invoke ExitProcess,0 end start </code></pre> <br /><h3>回答1:</h3><br /><p>Why are you doing a <code>fstp qword</code> (<code>double</code>) into a tbyte (<code>long double</code>)?</p> <p>Oh, that's probably your bug. Presumably the <code>invoke</code> macro pushes 12 bytes for each of the <code>result</code> macro args. (Because a 10-byte <code>tbyte</code> padded to a multiple of 4-byte stack slots is 12).</p> <p>But your format string only tells sprintf to look for <code>double</code> args, which are 8 bytes wide. Since you only stored a qword <code>double</code> to the low 8 bytes of <code>result</code>, <code>crt_sprintf</code> can correctly read the first variadic arg as a <code>double</code>. (x86 is little-endian so the low 8 bytes are at the stack address sprintf is looking at.)</p> <p><strong>But the 2nd <code>%G</code> conversion will be looking for another <code>double</code> right after the end of the previous arg. Which according to the format string should be 8 bytes later.</strong> But what your <code>invoke</code> actually pushed didn't match that. So the 2nd <code>%G</code> reads 8 bytes that overlap the two 12-byte pushes.</p> <p>It's probably <code>0</code> in the upper 4 bytes (including exponent and sign bit), and non-zero only in the low 31 bits of the mantissa, giving you a very small subnormal number. You can use a debugger to examine memory as a <code>double</code> and see that it represents the value sprintf read.</p> <p><strong><em>If</em> <code>long double</code> in that C library is the 10 byte x87 type, use <code>%LG</code> and use <code>fstp tbyte</code>.</strong></p> <p>If <code>sizeof(long double)</code> is only 8, then it's the same as <code>double</code> and you can't printf x87 tbyte values with that C library. (Unless it has some non-standard extension for it.) <strong>In that case You just change <code>result</code> to also be a <code>qword</code>, matching the store you're doing.</strong></p> <hr /><p>Also, you didn't balance the x87 stack; use faddp so it's empty after the <code>fstp</code>. (If your assembler requires an operand, use <code>faddp st(1)</code> or <code>st1</code>, however it likes to spell x87 register names.)</p> <p>You're technically violating the calling convention by making a function call with the x87 stack non-empty, but apparently crt_sprintf doesn't use all 8 of <code>st0..7</code> so it doesn't get a NaN from overflowing the x87 stack.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/60887371/cant-output-coprocessor-float-from-variable-two-times-in-a-row</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/assembly" hreflang="zh-hans">assembly</a></div> <div class="field--item"><a href="/tag/x86" hreflang="zh-hans">x86</a></div> <div class="field--item"><a href="/tag/masm" hreflang="zh-hans">MASM</a></div> <div class="field--item"><a href="/tag/masm32" hreflang="zh-hans">masm32</a></div> <div class="field--item"><a href="/tag/x87" hreflang="zh-hans">x87</a></div> </div> </div> Fri, 29 Jan 2021 06:35:55 +0000 谁说胖子不能爱 4040596 at http://www.e-learn.cn x86 MASM Assembly - Input Buffer holds old input despite FlushConsoleInputBuffer http://www.e-learn.cn/topic/4025657 <span>x86 MASM Assembly - Input Buffer holds old input despite FlushConsoleInputBuffer</span> <span><span lang="" about="/user/200" typeof="schema:Person" property="schema:name" datatype="">余生长醉</span></span> <span>2021-01-28 09:18:04</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>To practice assembly in MASM, I created a small program that is supposed to do the do the following:</p> <ol><li>Print "Type a: " to the screen</li> <li>Read one character from the input buffer, which is then flushed</li> <li>If the character is "a", then break away from the loop and end the program, if otherwise, repeat from step one</li> </ol><p>My code goes as follows:</p> <pre><code>.386 .model flat,stdcall include \masm32\include\kernel32.inc ; Defines Symbols To Be Used for the kernel32 library includelib \masm32\lib\kernel32.lib STD_OUTPUT_HANDLE equ -11 STD_INPUT_HANDLE equ -10 .code entryPt proc local inHandle:DWORD local outHandle:DWORD local noOfCharsWritten:DWORD ; Get Standard Output Handle push STD_OUTPUT_HANDLE call GetStdHandle mov outHandle,eax ; Get Standard Input Handle push STD_INPUT_HANDLE call GetStdHandle mov inHandle,eax .while (eax == eax) ; while (true) ; Print "Type a: " push 0 lea eax,noOfCharsWritten push eax push sizeof txt push offset txt push outHandle call WriteConsoleA ; Poll for a byte call getChar .if (al == "a") ; if the byte was "a"... .break ; ...then end the loop .endif .endw ; Leave with exit code 0 push 0 call ExitProcess entryPt endp getChar proc local inHandle:DWORD local noOfCharsRead:DWORD local resBt:BYTE ; Get the Standard Input Handle push STD_INPUT_HANDLE call GetStdHandle mov inHandle,eax ; Read one char from the console, put the result in resBt and the number of chars read in noOfCharsRead push 0 lea eax,noOfCharsRead push eax push 1 lea eax,resBt push eax push inHandle call ReadConsoleA ; Flush Console Input Buffer push inHandle call FlushConsoleInputBuffer ; Return the result in the accumulator movzx eax,resBt ret getChar endp .data txt db "Type a: " end entryPt </code></pre> <p>When typing "a", the program will exit, just like it should. However, should I type anything that is not "a" (for example, "s"), instead of inquiring "Type a: " again, only once, it will instead write "Type a: Type a: Type a:" before inquiring for another byte. Writing more than one non-a character will result in even more "Type a: "s.</p> <p>I suspect this is because <code>ReadConsole</code> is reading the older input and therefore terminating the function early, but shouldn't <code>FlushConsoleInputBuffer</code> have cleaned out the old input?</p> <br /><h3>回答1:</h3><br /><p><code>ReadConsole</code> reads <em>all</em> available characters from the console input buffer and stores them in a separate buffer that is not affected by <code>FlushConsoleInputBuffer</code>. You haven't a direct access to that buffer and can't get information about it. So, you have to read it with <code>ReadConsole</code> until the end of the line. By default, the end of the line is marked with the two bytes CR (0x0D) and LF (0x0A). Since you read just one byte, there is left at least the LF in the buffer.</p> <p>Replace the <code>FlushConsoleInputBuffer</code> with a <code>ReadConsole</code> loop to empty the buffer until LF is read:</p> <pre><code>.model flat,stdcall include \masm32\include\kernel32.inc ; Defines Symbols To Be Used for the kernel32 library includelib \masm32\lib\kernel32.lib STD_OUTPUT_HANDLE equ -11 STD_INPUT_HANDLE equ -10 .code entryPt proc local inHandle:DWORD local outHandle:DWORD local noOfCharsWritten:DWORD ; Get Standard Output Handle push STD_OUTPUT_HANDLE call GetStdHandle mov outHandle,eax ; Get Standard Input Handle push STD_INPUT_HANDLE call GetStdHandle mov inHandle,eax .while (eax == eax) ; while (true) ; Print "Type a: " push 0 lea eax,noOfCharsWritten push eax push sizeof txt push offset txt push outHandle call WriteConsoleA ; Poll for a byte call getChar .if (al == "a") ; if the byte was "a"... .break ; ...then end the loop .endif .endw ; Leave with exit code 0 push 0 call ExitProcess entryPt endp getChar proc local inHandle:DWORD local noOfCharsRead:DWORD local resBt:BYTE, dummy:BYTE ; Get the Standard Input Handle push STD_INPUT_HANDLE call GetStdHandle mov inHandle,eax ; Read one char from the console, put the result in resBt and the number of chars read in noOfCharsRead push 0 lea eax,noOfCharsRead push eax push 1 lea eax,resBt push eax push inHandle call ReadConsoleA ; Flush mov al, resBt mov dummy, al FlushLoop: cmp dummy, 0Ah je EndOfFlush invoke ReadConsoleA, inHandle, ADDR dummy, 1, ADDR noOfCharsRead, 0 jmp FlushLoop EndOfFlush: ; Return the result in the accumulator movzx eax,resBt ret getChar endp .data txt db "Type a: " end entryPt </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/53684281/x86-masm-assembly-input-buffer-holds-old-input-despite-flushconsoleinputbuffer</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/windows" hreflang="zh-hans">windows</a></div> <div class="field--item"><a href="/tag/winapi" hreflang="zh-hans">winapi</a></div> <div class="field--item"><a href="/tag/assembly" hreflang="zh-hans">assembly</a></div> <div class="field--item"><a href="/tag/x86" hreflang="zh-hans">x86</a></div> <div class="field--item"><a href="/tag/masm32" hreflang="zh-hans">masm32</a></div> </div> </div> Thu, 28 Jan 2021 01:18:04 +0000 余生长醉 4025657 at http://www.e-learn.cn x86 assembly extreme novice inquiry: “invalid instruction operands”? http://www.e-learn.cn/topic/3939632 <span>x86 assembly extreme novice inquiry: “invalid instruction operands”?</span> <span><span lang="" about="/user/105" typeof="schema:Person" property="schema:name" datatype="">岁酱吖の</span></span> <span>2020-11-29 10:09:03</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>The code below is only a small fraction of the program I am currently attempting to write, but no other parts of the program are relevant, so I only pasted what was necessary. Anyway, what I am trying to do is move the value stored within inputLoopCounter into ecx in order to determine how many times a loop should execute. However, when I attempt to assemble this program, I get the error mentioned in the question title. Can anybody explain the reason for this?</p> <pre><code>.data inputLoopCounter BYTE -1 .code mov ecx,inputLoopCounter </code></pre> <br /><h3>回答1:</h3><br /><p>One possible solution would be to replace <code>inputLoopCounter BYTE -1</code> by <code>inputLoopCounter DWORD -1</code>.</p> <br /><br /><br /><h3>回答2:</h3><br /><p>In MASM, <code>foo BYTE -1</code> is treated as declaring a "variable" with a fixed size. Using that symbol later implies an operand-size for instructions that access it.</p> <p>So MASM is trying to save you from yourself, stopping you from doing a dword (4-byte) load from a 1-byte variable. This happens even if you have multiple bytes, like <code>foo db "foobar"</code> and <em>want</em> to load multiple characters; that's when <code>mov eax, dword ptr [foo]</code> is useful.</p> <p>The other major flavour of Intel-syntax assembly language (NASM), will happily assemble an instruction that loads 4B from <code>[inputLoopCounter]</code>, regardless of what <code>inputLoopCounter</code> is a label for.</p> <p>In NASM, <code>mov [inputLoopCounter], 0</code> is a syntax error, because there's no implied operand-size from either operand. (And in MASM, it would be a <code>mov byte ptr [inputLoopCounter], 0</code>.)</p> <hr /><p>semi-related: Confusing brackets in MASM32 - <code>foo ptr [123]</code> works as an alternative to <code>ds:123</code> for indicating a memory operand, not an immediate, where insanely <code>[123]</code> would still be an immediate. Also related: Assembly difference between [var], and var</p> <hr /><p>If MASM allows it in the data section, <code>foo:</code> <code>db ...</code> would just declare a label without an implied size, separate from any data declaration.</p> <p>But apparently MASM does <em>not</em> support that in the data section, so you're stuck with variables, unless you want to switch assemblers. How to store 4 characters in a define doubleword in assembly language?</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/37034904/x86-assembly-extreme-novice-inquiry-invalid-instruction-operands</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/assembly" hreflang="zh-hans">assembly</a></div> <div class="field--item"><a href="/tag/x86" hreflang="zh-hans">x86</a></div> <div class="field--item"><a href="/tag/masm32" hreflang="zh-hans">masm32</a></div> </div> </div> Sun, 29 Nov 2020 02:09:03 +0000 岁酱吖の 3939632 at http://www.e-learn.cn x86 assembly extreme novice inquiry: “invalid instruction operands”? http://www.e-learn.cn/topic/3939631 <span>x86 assembly extreme novice inquiry: “invalid instruction operands”?</span> <span><span lang="" about="/user/17" typeof="schema:Person" property="schema:name" datatype="">…衆ロ難τιáo~</span></span> <span>2020-11-29 10:08:44</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>The code below is only a small fraction of the program I am currently attempting to write, but no other parts of the program are relevant, so I only pasted what was necessary. Anyway, what I am trying to do is move the value stored within inputLoopCounter into ecx in order to determine how many times a loop should execute. However, when I attempt to assemble this program, I get the error mentioned in the question title. Can anybody explain the reason for this?</p> <pre><code>.data inputLoopCounter BYTE -1 .code mov ecx,inputLoopCounter </code></pre> <br /><h3>回答1:</h3><br /><p>One possible solution would be to replace <code>inputLoopCounter BYTE -1</code> by <code>inputLoopCounter DWORD -1</code>.</p> <br /><br /><br /><h3>回答2:</h3><br /><p>In MASM, <code>foo BYTE -1</code> is treated as declaring a "variable" with a fixed size. Using that symbol later implies an operand-size for instructions that access it.</p> <p>So MASM is trying to save you from yourself, stopping you from doing a dword (4-byte) load from a 1-byte variable. This happens even if you have multiple bytes, like <code>foo db "foobar"</code> and <em>want</em> to load multiple characters; that's when <code>mov eax, dword ptr [foo]</code> is useful.</p> <p>The other major flavour of Intel-syntax assembly language (NASM), will happily assemble an instruction that loads 4B from <code>[inputLoopCounter]</code>, regardless of what <code>inputLoopCounter</code> is a label for.</p> <p>In NASM, <code>mov [inputLoopCounter], 0</code> is a syntax error, because there's no implied operand-size from either operand. (And in MASM, it would be a <code>mov byte ptr [inputLoopCounter], 0</code>.)</p> <hr /><p>semi-related: Confusing brackets in MASM32 - <code>foo ptr [123]</code> works as an alternative to <code>ds:123</code> for indicating a memory operand, not an immediate, where insanely <code>[123]</code> would still be an immediate. Also related: Assembly difference between [var], and var</p> <hr /><p>If MASM allows it in the data section, <code>foo:</code> <code>db ...</code> would just declare a label without an implied size, separate from any data declaration.</p> <p>But apparently MASM does <em>not</em> support that in the data section, so you're stuck with variables, unless you want to switch assemblers. How to store 4 characters in a define doubleword in assembly language?</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/37034904/x86-assembly-extreme-novice-inquiry-invalid-instruction-operands</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/assembly" hreflang="zh-hans">assembly</a></div> <div class="field--item"><a href="/tag/x86" hreflang="zh-hans">x86</a></div> <div class="field--item"><a href="/tag/masm32" hreflang="zh-hans">masm32</a></div> </div> </div> Sun, 29 Nov 2020 02:08:44 +0000 …衆ロ難τιáo~ 3939631 at http://www.e-learn.cn Confusing brackets in MASM32 http://www.e-learn.cn/topic/3522314 <span>Confusing brackets in MASM32</span> <span><span lang="" about="/user/240" typeof="schema:Person" property="schema:name" datatype="">北慕城南</span></span> <span>2020-03-23 08:18:12</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I am trying to get to grips with MASM32 and am confused by the following:</p> <p>I thought that brackets were used for indirection so if I have the a pre-defined variable</p> <pre><code> .data item dd 42 </code></pre> <p>then </p> <pre><code> mov ebx, item </code></pre> <p>would put the contents of 'item', i.e. the number 42, into ebx and</p> <pre><code> mov ebx, [item] </code></pre> <p>would put the address of 'item', i.e. where the 42 is stored, into ebx.</p> <p>But the following code in a console app:</p> <pre><code> mov ebx, item invoke dwtoa, ebx, ADDR valuestr invoke StdOut, ADDR valuestr mov ebx, [item] invoke dwtoa, ebx, ADDR valuestr invoke StdOut, ADDR valuestr </code></pre> <p>prints 42 twice. To get the address of 'item' I seem to need</p> <pre><code> mov ebx, [OFFSET item] invoke dwtoa, ebx, ADDR valuestr invoke StdOut, ADDR valuestr </code></pre> <p>Can anybody explain what square brackets are for in MASM, or point me at a good reference.</p> <br /><h3>回答1:</h3><br /><p>MASM is unusual for an assembly language in that is has types. MASM knows because of how you defined the symbol <code>item</code> that is a memory location of type <code>DWORD</code>. When you use it as an operand knows that you (probably) mean that you want the value stored at the address, not the value of the address. So it doesn't matter if you use <code>item</code> or <code>[item]</code> MASM assumes you mean the later. If you really want the address of item instead you need to use <code>OFFSET item</code>. </p> <p>On the other hand if you had defined <code>item</code> as constant using <code>item = 42</code> then <code>mov ebx, item</code> would load the immediate value. Because of this ambiguity, you need to know how <code>item</code> was defined to determine if it's an immediate operand or a memory operand, it's good idea to avoid using a bare symbol as an operand. </p> <p>I should add that the square brackets <code>[]</code> mean pretty much nothing to MASM when you're just using symbols or numbers. They only mean something when you use them with registers. Here's some examples:</p> <pre><code>item DD 42 const = 43 mov eax, item ; memory operand (the value stored at item) mov eax, [item] ; memory operand mov eax, OFFSET item ; immediate operand (the address of item) mov eax, [OFFSET item] ; immediate operand mov eax, const ; immediate operand (43) mov eax, [const] ; immediate operand mov eax, ds:[const] ; memory operand (the value at address 43) mov eax, fs:30h ; memory operand (the value at address 30h + fs base) mov eax, OFFSET const ; immediate operand mov eax, [OFFSET const] ; immediate operand mov eax, 42 ; immediate operand mov eax, ebx ; register operand (the value of EBX) mov eax, [ebx] ; indirect operand (the value pointed to by EBX) </code></pre> <p>So without registers square brackets only show your intent. You should put square brackets around symbols if you intend to use them as memory operands, and use <code>OFFSET</code> with symbols you intend to use as immediate values. </p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/60479552/difference-between-two-instructions-mov-eax-dword-ptr-fs30h-and-mov-eax-la</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/assembly" hreflang="zh-hans">assembly</a></div> <div class="field--item"><a href="/tag/masm" hreflang="zh-hans">MASM</a></div> <div class="field--item"><a href="/tag/masm32" hreflang="zh-hans">masm32</a></div> </div> </div> Mon, 23 Mar 2020 00:18:12 +0000 北慕城南 3522314 at http://www.e-learn.cn How do I write letter-initiated hexadecimal numbers in masm code? http://www.e-learn.cn/topic/3397583 <span>How do I write letter-initiated hexadecimal numbers in masm code?</span> <span><span lang="" about="/user/100" typeof="schema:Person" property="schema:name" datatype="">点点圈</span></span> <span>2020-02-16 10:30:08</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I am currently editing several macros consisting of MASM code. They all look similar to this:</p> <pre><code>Primary MACRO Key 0Bh,'0' Key 29h,15h Key 03h,'2' Key 06h,'5' Key 0Ch,'+' Key 0Dh,'´' Key 1Bh,'¨' Key 2Bh,27h Key 35h,'-' Key 34h,'.' Key 33h,',' Key 56h,'&lt;' ENDM </code></pre> <p>I have noticed that I can write hexadecimal numbers which are initiated by (begin with) character 0-9 in the following format: <code>02h</code>, <code>12h</code>, <code>5Ah</code>, etc. However, if I try to write letter-initiated hexadecimal numbers in the same way (that is, like <code>ABh</code>, <code>CAh</code>, <code>DFh</code>, etc.), I get an error. I have tried the format <code>0xBA</code>, <code>0xFE</code>, etc., but it doesn't work either. </p> <p>Can anyone tell me the correct format to use for writing letter-initiated hexadecimal numbers in this case?</p> <br /><h3>回答1:</h3><br /><p>The correct format for hex <code>AB</code> is <code>0ABh</code>.</p> <p>The reason you need to start it with a digit is so the assembler can easily distinguish it from a label or symbol such as <code>ABh</code>.</p> <p>And don't worry about the fact it has three digits. It doesn't magically turn into a twelve-bit number because of that, the number of bits used will depend on the addressing modes you're using.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/33276232/how-do-i-write-letter-initiated-hexadecimal-numbers-in-masm-code</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/assembly" hreflang="zh-hans">assembly</a></div> <div class="field--item"><a href="/tag/hex" hreflang="zh-hans">hex</a></div> <div class="field--item"><a href="/tag/masm32" hreflang="zh-hans">masm32</a></div> </div> </div> Sun, 16 Feb 2020 02:30:08 +0000 点点圈 3397583 at http://www.e-learn.cn Displaying Graphics in BIOS http://www.e-learn.cn/topic/3242015 <span>Displaying Graphics in BIOS</span> <span><span lang="" about="/user/35" typeof="schema:Person" property="schema:name" datatype="">99封情书</span></span> <span>2020-01-16 18:57:08</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>Using MASM32 is it possible to display bitmaps stored in a binary file embedded with the executable to the console?</p> <p>Can anyone show me how?</p> <p>Addendum: I'm not talking about a full fledge GUI here. Just the ability to display character bitmaps on the screen. They would be stored as 8x8 binary images in a file that we link to the executable.</p> <br /><h3>回答1:</h3><br /><p>You can do anything using MASM you could do with C or C++. However, using MASM doesn't give you any special abilities (you will still need to access the filesystem, for example), so if this is an attempt to get round the problems pointed out in answers to your previous question, you are out of luck.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/2272000/displaying-graphics-in-bios</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/assembly" hreflang="zh-hans">assembly</a></div> <div class="field--item"><a href="/tag/masm" hreflang="zh-hans">MASM</a></div> <div class="field--item"><a href="/tag/bios" hreflang="zh-hans">bios</a></div> <div class="field--item"><a href="/tag/masm32" hreflang="zh-hans">masm32</a></div> </div> </div> Thu, 16 Jan 2020 10:57:08 +0000 99封情书 3242015 at http://www.e-learn.cn Displaying Graphics in BIOS http://www.e-learn.cn/topic/3242005 <span>Displaying Graphics in BIOS</span> <span><span lang="" about="/user/155" typeof="schema:Person" property="schema:name" datatype="">和自甴很熟</span></span> <span>2020-01-16 18:56:20</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>Using MASM32 is it possible to display bitmaps stored in a binary file embedded with the executable to the console?</p> <p>Can anyone show me how?</p> <p>Addendum: I'm not talking about a full fledge GUI here. Just the ability to display character bitmaps on the screen. They would be stored as 8x8 binary images in a file that we link to the executable.</p> <br /><h3>回答1:</h3><br /><p>You can do anything using MASM you could do with C or C++. However, using MASM doesn't give you any special abilities (you will still need to access the filesystem, for example), so if this is an attempt to get round the problems pointed out in answers to your previous question, you are out of luck.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/2272000/displaying-graphics-in-bios</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/assembly" hreflang="zh-hans">assembly</a></div> <div class="field--item"><a href="/tag/masm" hreflang="zh-hans">MASM</a></div> <div class="field--item"><a href="/tag/bios" hreflang="zh-hans">bios</a></div> <div class="field--item"><a href="/tag/masm32" hreflang="zh-hans">masm32</a></div> </div> </div> Thu, 16 Jan 2020 10:56:20 +0000 和自甴很熟 3242005 at http://www.e-learn.cn Float data example using Masm http://www.e-learn.cn/topic/3220655 <span>Float data example using Masm</span> <span><span lang="" about="/user/212" typeof="schema:Person" property="schema:name" datatype="">三世轮回</span></span> <span>2020-01-15 03:28:11</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>Can somebody give me an example how to define a float number or constant in data section of MASM? Or at least some information about it...</p> <br /><h3>回答1:</h3><br /><p>I think it's done with</p> <pre><code>.data myVar REAL4 1.0f .code </code></pre> <p>Floating point values are REAL4, REAL8 or REAL10 in Masm.<br /> Expressions (such as #define myConst 1.0f) are done with <code>myConst EQU 1.0</code> </p> <p>These are not specific to any section.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/13703907/float-data-example-using-masm</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/assembly" hreflang="zh-hans">assembly</a></div> <div class="field--item"><a href="/tag/floating-point" hreflang="zh-hans">floating-point</a></div> <div class="field--item"><a href="/tag/masm32" hreflang="zh-hans">masm32</a></div> </div> </div> Tue, 14 Jan 2020 19:28:11 +0000 三世轮回 3220655 at http://www.e-learn.cn How does MASM .DATA? directive work internally [duplicate] http://www.e-learn.cn/topic/3203159 <span>How does MASM .DATA? directive work internally [duplicate]</span> <span><span lang="" about="/user/77" typeof="schema:Person" property="schema:name" datatype="">只愿长相守</span></span> <span>2020-01-13 16:56:12</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><aside class="s-notice s-notice__info js-post-notice mb16" aria-hidden="false" role="status"><div class="grid fd-column fw-nowrap"> <div class="grid fw-nowrap"> <div class="grid--cell fl1 lh-lg"> <div class="grid--cell fl1 lh-lg"> <b>This question already has an answer here</b>: </div> </div> </div> <div class="grid--cell mb0 mt4"> How to see the memory occupied by initialised array vs uninitialised array <span class="question-originals-answer-count"> (1 answer) </span> </div> <div class="grid--cell mb0 mt8">Closed <span title="2017-06-28 04:29:22Z" class="relativetime">2 years ago</span>.</div> </div> </aside><p>In Kip Irvines book I came across the following :</p> <p>The .DATA? directive declares uninitialized data. When defining a large block of uninitialized data, the .DATA? directive reduces the size of a compiled program. For example, the followingcode is declared efficiently:</p> <blockquote> <p>.data?</p> <p>bigArray DWORD 5000 DUP(?) ; 20,000 bytes, not initialized</p> </blockquote> <p>The following code, on the other hand, produces a compiled program 20,000 bytes <strong>larger</strong>:</p> <blockquote> <p>.data</p> <p>bigArray DWORD 5000 DUP(?) ; 20,000 bytes</p> </blockquote> <p>What exactly is the .data? directive doing under the hood in the above example to make the program 20k smaller.</p> <br /><h3>回答1:</h3><br /><p>The uninitialized data need not be in the compiled binary, just a byte count that the OS loader allocates at run-time when executing your program.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/7137049/how-does-masm-data-directive-work-internally</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/assembly" hreflang="zh-hans">assembly</a></div> <div class="field--item"><a href="/tag/masm32" hreflang="zh-hans">masm32</a></div> </div> </div> Mon, 13 Jan 2020 08:56:12 +0000 只愿长相守 3203159 at http://www.e-learn.cn