Writing Hello World in assembler for Windows RT using winapi

  • Tutorial
One day, more recently, Microsoft lost millions of dollars on Windows tablets . Well, today we’ll just write them in assembler.

We will need the following things.
  • Installed Microsoft Visual Studio with support for ARM assembler, for example 2012.
  • Jailbreak'in tablet with installed Windows RT, for example Microsoft Surface RT.

First, create a separate folder for the project, in which we create the arm.asm file, the contents of which are under the cut.

	AREA	data, DATA
Text	DCB "Hello world(text)", 0x0
Caption	DCB "Hello world(caption)", 0x0
	EXPORT	WinMainCRTStartup
	IMPORT	__imp_MessageBoxA
	IMPORT	__imp_ExitProcess
	AREA	text, CODE
WinMainCRTStartup	PROC
			movs        r3,#0
			ldr         r2,Caption_ptr
			ldr         r1,Text_ptr
			movs        r0,#0
			ldr         r4,MessageBoxA_ptr
			ldr         r4,[r4]
			blx         r4
			movs        r0,#0
			ldr         r4,ExitProcess_ptr
			ldr         r4,[r4]
			blx         r4
MessageBoxA_ptr	DCD	__imp_MessageBoxA
ExitProcess_ptr	DCD	__imp_ExitProcess
Text_ptr	DCD	Text
Caption_ptr	DCD	Caption

Moreover, the assembler as part of Visual Studio 2012 noticed a strange thing: macros and instructions must contain at least one tabulation character, but labels and names of memory areas, on the contrary, should not contain anything in front of them (i.e., they should start immediately from the beginning lines), otherwise there will be errors.

So, we typed the text, now let's start compilation. From the Start menu, run:
Microsoft Visual Studio 2012 - Visual Studio Tools - Command Line VS2012 ARM Cross Tools .
From the command input window that opens, go to the source directory, for example:
cd \my_arm_proj

Next, we enter the commands:
armasm arm.asm
link arm.obj user32.lib kernel32.lib /subsystem:windows

As a result, at the output to the program directories we get the executable file arm.exe. Copy it to the tablet, and voila!

Also popular now: