NO

Author Topic: need a sample for x86 assembly file and compile and linking syntax..Appriciated  (Read 1109 times)

Offline sydhsnazm

  • Member
  • *
  • Posts: 1
  • love to print helloworld!
need a sample for x86 assembly file and compile and linking syntax..Appriciated

e.g.
<------------------------------------>
.386
.model flat, stdcall
option casemap : none
.code
start:
    ;write your code here
    xor eax, eax
    mov eax,6H
    ret
    end start
<------------------------------------------->
above  file is for masm x86 and compile syntax is as follows ,remove square brackets please.

ml.exe /nologo /Sn /Sa /c /coff /Fo[PROGRAM_NAME.OBJ] /Fl[LSTOUTPUT_NAME.LST] [PROGRAM_NAME.ASM]

and linking is as follows  ,remove square brackets please.

link.exe /SUBSYSTEM:CONSOLE /OPT:NOREF /NOLOGO /OUT:[PROGRAM_NAME.EXE] [PROGRAM_NAME.OBJ]

thanks in advance.

SMH

Offline Vortex

  • Member
  • *
  • Posts: 841
    • http://www.vortex.masmcode.com
Hi sydhsnazm,

Welcome to the Pelles C forum. You would like to use Pelle's Macro Assembler Poasm which has very similar syntax to that of Masm.

Code: [Select]
.386
.model flat,stdcall
option casemap:none

ExitProcess PROTO :DWORD
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD
MessageBox TEXTEQU <MessageBoxA>

includelib kernel32.lib
includelib user32.lib

MB_OK equ 0

.data

msg     db 'Hello world!',0
capt    db 'Message box',0

.code

start:

    invoke  MessageBox,0,ADDR msg,ADDR capt,MB_OK
    invoke  ExitProcess,0

END start

Assembling the code :

Code: [Select]
\PellesC\bin\poasm /AIA32 Hello.asm
\PellesC\bin\polink /SUBSYSTEM:WINDOWS /LIBPATH:\PellesC\Lib\Win Hello.obj
Code it... That's all...