Re: GAS-Intel on Windows (MinGW)
- From: nbaker2328 <spamtrap@xxxxxxxxxx>
- Date: Tue, 12 Feb 2008 10:48:37 -0800 (PST)
On Feb 11, 5:15 pm, yaugin <spamt...@xxxxxxxxxx> wrote:
Hello all, I am trying to get the hang of using GAS Intel syntax on
Windows, via the MinGW ports of as and ld. The following is an attempt
at a Hello World on the Windows console. It assembles, links, and runs
without error, but doesn't do anything (no Hello World output).
.intel_syntax noprefix
.global start
.section .text
start:
.extern _GetStdHandle@4 # to use the console
push -11 # STD_OUTPUT_HANDLE
call _GetStdHandle@4 # put handle in EAX
.extern _WriteConsoleA@20 # to print text
push 0 # lpReserved = NULL
push written # nNumberOfCharsWritten (ptr)
push 11 # nNumberOfCharsToWrite = 11
push buffer # lpBuffer (ptr)
push eax # handle from GetStdHandle
call _WriteConsoleA@20
.extern _ExitProcess@4
push 0
call _ExitProcess@4
.section .data
buffer: .asciz "Hello World"
.section .bss
.lcomm written, 4 # reserve 4 bytes
This was converted from a working NASM program:
global start
segment .text
start:
extern _GetStdHandle@4 ; to use the console
push -11 ; STD_OUTPUT_HANDLE
call _GetStdHandle@4 ; put handle in EAX
extern _WriteConsoleA@20 ; to print text
push 0 ; lpReserved = NULL
push written ; nNumberOfCharsWritten (ptr)
push 11 ; nNumberOfCharsToWrite = 11
push buffer ; lpBuffer (ptr)
push eax ; handle from GetStdHandle
call _WriteConsoleA@20
extern _ExitProcess@4
push 0
call _ExitProcess@4
segment .data
buffer dd 'Hello World'
segment .bss
written resd 1 ; reserve a double
Use your editor's *Search and Replace* feature to change
"WriteConsole" to "WriteFile" throughout the entire source.
Nathan.
.
- Follow-Ups:
- Re: GAS-Intel on Windows (MinGW)
- From: ArarghMail802NOSPAM
- Re: GAS-Intel on Windows (MinGW)
- References:
- GAS-Intel on Windows (MinGW)
- From: yaugin
- GAS-Intel on Windows (MinGW)
- Prev by Date: Re: Accessing Physical Memory & Other Process's Address Space
- Next by Date: Re: GAS-Intel on Windows (MinGW)
- Previous by thread: Re: GAS-Intel on Windows (MinGW)
- Next by thread: Re: GAS-Intel on Windows (MinGW)
- Index(es):