How does one display "Hello, world!" without using the benefits of a high-level assembler?

Related searches

I'm attempting to display "Hello, world!" with FASM on a 64-bit Windows 7 machine without using the crutches that modern assemblers seem to provide in abundance.

This rather simple task proved to be surprisingly frustrating since every example and tutorial I could find insists on resorting to macros, including prewritten code, or importing libraries from high-level languages. I thought that the kind of people who want to learn assembly typically do so to develop a direct and intimate understanding of how computers work. All these abstractions and obfuscations seem to detract from that purpose.

Rant aside, I'm looking for code that can display "Hello, world!" on a console without reusing, including, and importing anything except to directly access the Windows API. Although I'm aware that many assemblers come packaged with files that provide access to the Windows API, I'd rather not rely on them.

Also, if you have any suggestions as to what assemblers or tutorials I can use to better facilitate my approach to learning, I'd greatly appreciate it.

The big problem with "pure" windows programming is that Windows require that the program contains import section, about what functions from the system DLLs have to be provided to the program - so called import table.

This table is not a part of the program and has nothing to do with assembly programming itself. Besides, the import table has complex structure, not very convenient to be manually build. That is why FASM provides some standard way for the user to build these import tables.

The proper approach to you, if you goal is to learn assembly, is to read the FASM manuals, where these macros are described, then to read the example code provided in any FASM distribution and then to start using them and concentrate to the assembly programming.

The moderate use of macros does not make your program less assembly written!

The FASM message board is good place to ask questions and to get help, but you have to make your homework after all.

Dual Screen Setup for Desktop Computer Monitors, Do you want to combine 2 desktop computer monitors into one gigantic work space? Learn how to set the primary and secondary monitors, resolution, display � Write a document on one screen while referencing web pages on your other screen, or game on one while chatting in Discord on the other. But don't just plug in a second display and call it a day

Every running process under windows gets either kernel32 or kernalbase loaded into its address space, using this fact and the PEB internals, you can easily access any windows function (provided you have the right access privileges).

This blog entry details how to go about doing this to display a message with MessageBoxA.

In all honesty, unless you have some extreme reason for doing this, you are going to just end up wasting time, rather use the tools provided (in this case, a linker, so you can access any windows API without going through 10000 hurdles and loops).

Driving Multiple Displays from a Single DisplayPort Output , Multi-stream enabled display products, including monitor hubs and daisy- chainable monitors, should become widely available as more DisplayPort 1.2 enabled� One Exception in Changing Main Display. If you choose to extend your displays, or make one of them your standalone monitor, a main display will have to get selected. However, that’s not the case with duplicating. Duplicating simply makes all of the displays the main display. So, if all of them are the main display, then none of them are.

I managed to link to one library only (kernel32.dll) and make reference to 3 functions:




The code below is the result of my exhaustive Google search, and my own reference to MS documentation.

format PE console
entry start

include 'include\'

section '.data' data readable writable
     msg     db 'Hello World!',13,10,0
     len = $-msg
     dummy   dd ?

section '.code' readable writable executable


call [GetStdHandle] ;STD_OUTPUT_HANDLE (DWORD)-11

push 0      ;LPVOID  lpReserved
push dummy  ;LPDWORD lpNumberOfCharsWritten
push len    ;DWORD   nNumberOfCharsToWrite
push msg    ;VOID    *lpBuffer;
push eax    ;HANDLE  hConsoleOutput
call [WriteConsole]

push 0
call [ExitProcess]

section '.idata' data import readable writable

library kernel32,'KERNEL32.DLL' 
include 'include\api\'

Multi-monitor, Implementation[edit]. Analog Monitor Splitter for VGA cable. Multiple computers can be connected to provide a single display,� So how do you keep your built-in computer display turned off while keeping your files and programs actively running on your external display? This is a very easy problem to solve. In fact, it’s so easy that you can set your computer to automatically turn off its own display and push everything to your external display the next time you set it up.

  1. Asking google for help:
  2. Trying to do it yourself

 ; Example of 64-bit PE program 

format PE64 GUI 
entry start 

section '.text' code readable executable 

      sub     rsp,8*5         ; reserve stack for API use and make stack dqword aligned 

    mov     r9d,0 
    lea     r8,[_caption] 
    lea     rdx,[_message] 
    mov    rcx,0 
    call    [MessageBoxA] 

    mov     ecx,eax 
    call    [ExitProcess] 

section '.data' data readable writeable 

  _caption db 'Win64 assembly program',0 
  _message db 'Hello World!',0 

section '.idata' import data readable writeable 

  dd 0,0,0,RVA kernel_name,RVA kernel_table 
  dd 0,0,0,RVA user_name,RVA user_table 
  dd 0,0,0,0,0 

    ExitProcess dq RVA _ExitProcess 
    dq 0 
    MessageBoxA dq RVA _MessageBoxA 
    dq 0 

  kernel_name db 'KERNEL32.DLL',0 
  user_name db 'USER32.DLL',0 

  _ExitProcess dw 0 
    db 'ExitProcess',0 
  _MessageBoxA dw 0 
    db 'MessageBoxA',0

Using nasm to compile this hello world (16 bit) code taken from here:

.model tiny
org 100h

main  proc

      mov    ah,9                       ; Display String Service
      mov    dx,offset hello_message    ; Offset of message (Segment DS is the right segment in .COM files)
      int    21h                        ; call DOS int 21h service to display message at ptr ds:dx

      retn                              ; returns to address 0000 off the stack 
                                        ; which points to bytes which make int 20h (exit program)

hello_message db 'Hello, world!$'

main  endp
end   main

How to use multiple monitors in Windows 10, Rearrange your displays. You'll see this option when Windows detects more than one display. Each display will be numbered to help you identify� So that you can move apps and windows across your displays in one continuous motion, arrange your displays to match the setup on your desk. You can also change your primary display, which is where your desktop icons and app windows first appear.

How to set up two monitors for double the screen real estate, How to set up dual monitors. Step 1: This part is easy. Simply connect your second monitor to a power outlet and an available port on your PC. How to use the Wireless Display app on Xbox One. The Xbox One Wireless Display app is actually the same casting experience you can find on a Microsoft Surface Hub or Windows 10. As stated above

This video informs you of the options for connecting your device to a second display using Windows 10. Depending on the age of the devices available, you can connect to a second screen by a VGI, DVI, HDMI, or Mini Display Port. As you will see, the easiest way to project the screen is by […]

Windows chooses the best display settings for your PC based on your monitor. If you want to adjust your display settings, or if they were changed and you want to restore default settings, here are a few things you can try.

  • The system call IDs in Windows differ between different versions of Windows. I don't see much point in that, but that's how things are. This is why you want to import a few system DLLs, which have those system call IDs inside, and use the wrapper functions from those DLLs to get the job done. I don't think reverse engineering those DLLs and the OS kernel is going to save you time. Just use the DLLs.
  • @JohnMcClane Why don't you use console functions like WriteConsole?… This is a C example:
  • I had already seen that. And while I appreciate your response, I was looking to display "Hello, world!" to the console, which I heard is much more complex than displaying it in a window.
  • Thank you, but that code is for DOS. There's a Windows example on the same page, but it says to use include which is what I'm trying to avoid.
  • The x86-64 part of this answer looks good as far as showing how to manually import WinAPI function. The DOS part is totally irrelevant for Windows. The Windows equivalent would be directly using x86-64 syscall for some version of Windows (undocumented and unsupported, and call numbers can change between Windows version, unlike on Linux where the direct system-call ABI is stable.).