Assembly language > Assembly discussions

I am begginer

<< < (2/3) > >>

zellJunior:
Thanks a lot to all, i need to study more POASM structure. A very good example from "timovjl" <-- thanks. I would appreciate if someone wold give an example how to shoe "Hello" to console. 

jj2007:
Sure, here it is:

.486         ; create 32 bit code
.model flat, stdcall   ; 32 bit memory model
option casemap :none   ; case sensitive

includelib kernel32.lib

.code
TheMessage   db "PoAsm is great:", 0

ConOut proc lpszText, sl
LOCAL bytesWritten
   invoke GetStdHandle, -11   ; STD_OUTPUT_HANDLE
   xchg eax, ecx
   invoke WriteFile, ecx, lpszText, sl, addr bytesWritten, 0
   ret
ConOut endp

start:   
   invoke ConOut, addr TheMessage, sizeof TheMessage
   invoke ExitProcess, 0
end start

TimoVJL:
Simpler minimal version:

--- Code: ---.486         ; create 32 bit code
.model flat, stdcall   ; 32 bit memory model
option casemap :none   ; case sensitive

includelib kernel32.lib

ExitProcess proto : DWORD
GetStdHandle    PROTO :DWORD
WriteFile       PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD

.data
msg   db "PoAsm is great!",13,10,0
numw  dd 0

.code
start:
   invoke GetStdHandle, -11
   invoke WriteFile, eax, addr msg, sizeof msg, addr numw, 0
   invoke ExitProcess, 0
end start
--- End code ---
When using debugger this one using PROC and ENDP works better:
--- Code: ---.486         ; create 32 bit code
.MODEL FLAT, STDCALL   ; 32 bit memory model
OPTION CASEMAP :NONE   ; case sensitive

INCLUDELIB kernel32.lib

ExitProcess  PROTO :DWORD
GetStdHandle PROTO :DWORD
WriteFile    PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD

.data
msg   db "PoAsm is great!",13,10,0
numw  dd 0

.code
start PROC
   INVOKE GetStdHandle, -11
   INVOKE WriteFile, eax, ADDR msg, SIZEOF msg, ADDR numw, 0
   INVOKE ExitProcess, 0
start ENDP
END start
--- End code ---

Bitbeisser:

--- Quote from: jj2007 on February 05, 2014, 10:59:20 PM ---... besides, I find your attempt to push the OP to continue with JWasm and 16-bit code utterly anachronistic.

--- End quote ---
Given that he states in his (her?) subject that (s)he is a beginner, without any indication of what his/her problem is (s)he ran into and what the purpose for trying to get this exact example, which is clearly 16bit DOS based code (hence INT21h calls), I think that referring to a cleaner, DOS based assembler is rather appropriate than anachronistic.
Understanding how x86 assembler works is one thing, understanding what is required to get this working in Windows is a completely different ball game.

Basics never change, environments do...

Ralf

jj2007:

--- Quote from: Bitbeisser on February 05, 2014, 11:34:42 PM ---without any indication of what his/her problem is
--- End quote ---


--- Quote from: zellJunior on February 05, 2014, 09:17:49 PM ---Please someone help me adapt this code to POASM
--- End quote ---

This is what Timo and I have done. Re environments, for console apps the switch from DOS to Win32 is not a big issue.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version