MASM

external assembly file in visual studio

百般思念 提交于 2019-11-28 04:35:17
I searched and found I can not use __asm in x64 in visual studio. Instead I have to use an external assembly file. How can I add external assembly file to my win32 console project? How can compile them? Can you explain step by step. How to build a mixed-source x64-project with a x64 assembly file in Visual Studio : 1) Start Visual Studio (Community) 2015 and choose FILE - New - Project . 2) In the next window choose Win 32 Console Application . 3) You get a confirmation. Click on Next > . 4) In the next window you can accept the default settings. Click on Finish . 5) Now choose PROJECT - Build

Why does using “int 21h” on Assembly x86 MASM cause my program to crash?

£可爱£侵袭症+ 提交于 2019-11-28 02:28:59
I was trying to make my program accept input without the user having to press enter, so I tried the following: mov ah,01h int 21h But it just crashes my program over an unhandled exception . This seems to be the way to do it according to much that I have read, so why isn't it working for me? Now, I am fairly new to this language so I still do not exactly understand the process of how this piece of code works, so I would also appreciate what the logic is behind accepting input by pressing enter and accepting input without the user having to press enter. MY OS is Windows, by the way. Your code

How do we clear the console in assembly?

☆樱花仙子☆ 提交于 2019-11-28 02:05:05
I am looking for a win32 api function that clears the console, much like the cls command Thanks! Devjeet This is pretty old, but should still work. Conversion to assembly language is left as an exercise for the reader, but shouldn't be terribly difficult (most of it is just function calls, and the multiplication is trivial): #include <windows.h> void clear_screen(char fill = ' ') { COORD tl = {0,0}; CONSOLE_SCREEN_BUFFER_INFO s; HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(console, &s); DWORD written, cells = s.dwSize.X * s.dwSize.Y; FillConsoleOutputCharacter

Making assembly function inline in x64 Visual Studio

一曲冷凌霜 提交于 2019-11-28 00:52:14
问题 I know that MSVC compiler in x64 mode does not support inline assembly snippets of code, and in order to use assembly code you have to define your function in some external my_asm_funcs.asm file like that: my_asm_func PROC mov rax, rcx ret my_asm_func ENDP And then in your .c or .h file you define a header for the function like that: int my_asm_func(int x); Although that solution answers many concerns, but I am still interested in making that assembly code function to be inline, in other

Why doesn't MS-DOS initialize the DS and ES registers?

依然范特西╮ 提交于 2019-11-28 00:24:35
问题 Why does the initialization of the DS and ES registers has to be done manually by the programmer? For example: MOV AX, DTSEG MOV DS, AX On the other hand, the CS and SS registers are initialized by the operating system (in MS-DOS ). Why is this so? 回答1: Because CS and SS registers are essential for program execution in contrast to DS and ES registers which point to user-defined data segments. By default no data is present in the executing program this nothing to initialize the DS and ES with.

MASM/NASM Differences

杀马特。学长 韩版系。学妹 提交于 2019-11-27 19:59:39
What are the syntax differences between the NASM and MASM assemblers? Section 2.2 of the NASM documentation is titled Quick Start for MASM Users which lists the important differences between NASM and MASM. 来源: https://stackoverflow.com/questions/2035747/masm-nasm-differences

How to code a far absolute JMP/CALL instruction in MASM?

烂漫一生 提交于 2019-11-27 16:14:50
How can I write a far absolute JMP or CALL instruction using MASM? Specifically how do I get it to emit these instruction using the EA and CA opcodes, without manually emitting them using DB or other data directives? For example consider the case of jumping to the BIOS reset entry point at FFFF:0000 in a boot sector. If I were using NASM I could code this in one instruction in the obvious way: jmp 0xffff:0 With the GNU assembler the syntax is less obvious, but the following will do the job: jmp 0xffff, 0 However when I try the obvious solution with MASM: jmp 0ffffh:0 I get the following error:

Illegal use of register in indirect addressing

核能气质少年 提交于 2019-11-27 15:56:23
I'm trying to write a subroutine that adds two large numbers in x86 assembly (MASM). The numbers are pointed at by the si and di registers, and the function should iterate from right to left, adding each data word and passing the carry, and saving the result in di. The number of data words to add is determined by a previous chunk of code. ... mov cx, ( number of data words to add ) adding: mov bx,cx ;copy the loop counter to bx lea ax,[di+2*bx] ;move ax to the destination word adc ax,[si+2*bx] ;add the source word into the destination word loop adding ;main sub loop ... Unfortunately, when I

Execute RDMSR and WRMSR instructions from C/C++ code

那年仲夏 提交于 2019-11-27 15:25:29
问题 I need to control C-State configuration. Specifically, I'd probably like to execute the following asm code: __asm { rdmsr and eax, 0x00 or eax, 0x01 wrmsr } Currently, I got this exception on rdmsr line: Unhandled exception at 0x00e3139e in MessWithCStates.exe: 0xC0000096: Privileged instruction. How can I (permanently) elevate priviliges of my app so it could execute the code above? I use VS 2010. NOTE: It is possible without writing a kernel-mode driver. See R/W Everything . 回答1: Chances

How to print colored string in assembly language?

大兔子大兔子 提交于 2019-11-27 09:39:37
Jan db " January$ " string db "Sun Mon Tue Wed Thu Fri Sat$" string1 db " 1 2 3$" string2 db " 4 5 6 7 8 9 10$" string3 db "11 12 13 14 15 16 17$" string4 db "18 19 20 21 22 23 24$" string5 db "25 26 27 28 29 30 31$" There are several ways to achieve your goal IN TEXT MODE : Display char by char : this way you can choose one color for every character. Access screen memory : at segment 0B800:0. Display the whole string with the same color. Next code does the job with the third option (the easiest). It was made with EMU8086: .stack 100h .data Jan db " January ",13,10 db "Sun Mon Tue Wed Thu Fri