I'm looking into doing C++ and assembly language on Windows 10. I'm starting with x64 asm on the desktop, then down the track I would like to try ARM asm on Win 10 IOT Core.
The project will typically have considerable amount of C++ code, and some assembly language code, but see I will see where it goes. Why use assembly? Purely for fun. This whole project is a hobby to get back into C++ and assembly.
UWP C++ appears to be the way to go, ie latest Microsoft programming technology. Windows Desktop C++ (ie Win32 or console) is still supported, but I'd rather stick with UWP.
I've had a quick read on UWP C++, learn't the basics on XAML, and C++ is coming back to me (I hadn't touched it in years).
Using Visual Studio Professional (with masm under the hood) and x64 asm.
I have a simple Hello World application. A textbox and a button. The project includes an .asm file which contains a simple function which adds two numbers and returns the result in rax. This (asm) function is called in the button click event and outputs to the textbox text.
MainPage.xaml.cpp
extern "C" int SomeFunction();
void LearningUWPwithCPP::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
greetingOutput->Text = SomeFunction().ToString();
}
MainPage.xaml
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel x:Name="contentPanel" Margin="120,30,0,0">
<TextBlock HorizontalAlignment="Left" Text="Hello World" FontSize="36"/>
<TextBlock Text="Click the button"/>
<Button x:Name="inputButton" Content="Click me" Click="Button_Click"/>
<TextBlock x:Name="greetingOutput"/>
</StackPanel>
</Grid>
TestASM.asm
.CODE
SomeFunction PROC
mov rax, 5
add rax, 6
ret
SomeFunction ENDP
END
Further info...
The problem: I'm getting an "unresolved externals" error
Helpful tips
With these points, it's very obvious the project isn't finding my asm file. I'm not sure how to include an asm file. And I suspect extern is a remnant of the Win32 C++ days and perhaps can't be used in UWP.
Any help is much appreciated.
Depending on the order you do things, certain properties for asm files in the VS Solution Explorer can get set incorrectly.
Common solutions include removing/re-adding the asm file from the solution explorer, or manually setting Excluded from Build
to no and Item Type
to Microsoft Macro Assembler for each build configuration.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.