I have tasm, anyone know how to make a windows app in it? I tried using the master tutorials from icz's site, but i get an illegal operation error everytime i run the app.
Posted on 2001-10-22 21:16:11 by ChimpFace9000
well this is not TASM is NASM

and i have translated from an example made in TASM

to NASM syntax it is an IP RESOLVER :



;====================================
;= Functions that we are going to use from Window system
;====================================

extern GetModuleHandleA
extern DialogBoxParamA
extern GetDlgItemTextA
extern SetDlgItemTextA
extern LoadIconA
extern SendDlgItemMessageA
extern ExitProcess
import WSAStartup wsock32.dll
extern WSAStartup
import WSACleanup wsock32.dll
extern WSACleanup
import gethostbyaddr wsock32.dll
extern gethostbyaddr
import gethostbyname wsock32.dll
extern gethostbyname
import inet_addr wsock32.dll
extern inet_addr
import inet_ntoa wsock32.dll
extern inet_ntoa
extern lstrlen
extern SendMessageA
extern PostQuitMessage
extern MessageBoxA
extern lstrcmp

%include '\nagoa\vasm\inc\win32n.inc'


%macro call 2-*
%define _j %1
%rep %0-1
%rotate -1
push dword %1
%endrep
call _j
%endmacro

ICON_SMALL equ 0
ICON_BIG equ 1

IDD_DIALOG1 equ 101
IDC_HOSTNAME equ 1000
IDC_IP equ 1001
IDC_STATIC equ -1
IDI_ICON1 equ 102




WS_Error db 'Error initializing Winsock!',0
caption db 'Host/IP Resolver v0.1',0
db '(c)1999 by Jeremy Collake',0
unknown db '<Unknown>',0
cip dd 0
hInst dd 0
hwnd dd 0
WSAStruct resb WSAdata_size

ipaddr resb 256
hostname resb 256




..start:

enter 0,0
call GetModuleHandleA, NULL
mov , eax
call DialogBoxParamA, ,101 , 0, @WndProc, 0
call ExitProcess,


@WndProc:
%define hwnd ebp+8
%define wmsg ebp+12
%define wparam ebp+16
%define lparam ebp+20


enter 0,0
cmp dword ,WM_INITDIALOG
je init
cmp dword ,WM_CLOSE
je near close
cmp dword ,WM_DESTROY
je near close
cmp dword ,WM_COMMAND
je wmcommand
jmp unhandled

unhandled:

mov eax,0
leave
ret 16

init:

call ,101h, WSAStruct
or eax,eax
jz .WsockFine
call MessageBoxA,0, WS_Error, caption,MB_ICONHAND
call ExitProcess,0


.WsockFine


mov eax,1
leave
ret 16



wmcommand:
cmp dword ,IDCANCEL ; close
je near close
cmp dword ,IDOK ;resolve ip
je resolve

mov eax,1
leave
ret 16



resolve:
pushad
call GetDlgItemTextA,,IDC_IP, ipaddr,255
or eax,eax
jz ResolveHost
call lstrcmp, unknown, ipaddr
or eax,eax
jz ResolveHost
call , ipaddr
mov ,eax
call , ,4,2
mov ebx,IDC_HOSTNAME
or eax,eax
jz Unresolvable
mov eax,
or eax,eax
jz Unresolvable
call SetDlgItemTextA,,IDC_HOSTNAME,eax
jmp eResolve
Unresolvable:
call SetDlgItemTextA,,ebx, unknown
jmp eResolve
ResolveHost:
call GetDlgItemTextA,,IDC_HOSTNAME, hostname,255
or eax,eax
jz eResolve
call lstrcmp, unknown, hostname
or eax,eax
jz eResolve
call , hostname
mov ebx,IDC_IP
or eax,eax
jz Unresolvable
mov eax,
mov eax,
mov eax,
call ,eax
call SetDlgItemTextA,,IDC_IP,eax
eResolve:
popad
jmp unhandled



close:
call
call ExitProcess,0
ret16


;*********



NASM is better then Tasm and then Masm









know is the TASM version:



include resolver.inc
include mywin.inc

.486p
locals
jumps
.model flat,STDCALL

extrn GetModuleHandleA:PROC
extrn DialogBoxParamA:PROC
extrn GetDlgItemTextA:PROC
extrn SetDlgItemTextA:PROC
extrn LoadIconA:PROC
extrn SendDlgItemMessageA:PROC
extrn ExitProcess:PROC
extrn WSAStartup:PROC
extrn WSACleanup:PROC
extrn gethostbyaddr:PROC
extrn gethostbyname:PROC
extrn inet_addr:PROC
extrn inet_ntoa:PROC
extrn lstrlen:PROC
extrn SendMessageA:PROC
extrn PostQuitMessage:PROC
extrn MessageBoxA:PROC
extrn lstrcmp:PROC

.data
WS_Error db 'Error initializing Winsock!',0
caption db 'Host/IP Resolver v0.1',0
db '(c)1999 by Jeremy Collake',0
unknown db '<Unknown>',0
cip dd ?
hInst dd ?
hMain dd ?
WSAStruct WSADATA <?>
dd ? ; for structure alignment
ipaddr db 256 dup(?)
hostname db 256 dup(?)
.code
start:
call GetModuleHandleA,0
mov hInst,eax

call WSAStartup,101h,offset WSAStruct
or eax,eax
jz WsockFine
call MessageBoxA,0,offset WS_Error,offset caption,MB_ICONHAND
call ExitProcess,1
WsockFine:
call DialogBoxParamA, eax, IDD_DIALOG1, 0, offset WndProc, 0
call ExitProcess,0

WndProc PROC hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD
USES ebx, edi, esi
cmp wmsg,WM_INITDIALOG
jz init
cmp wmsg,WM_CLOSE
jz close
cmp wmsg,WM_DESTROY
jz close
cmp wmsg,WM_COMMAND
jz cmd_switch
WEndUnprocessed:
xor eax,eax
ret
cmd_switch:
cmp wparam,IDCANCEL
jz close
cmp wparam,IDOK
jnz WEndUnprocessed
resolve:
pushad
call GetDlgItemTextA,hMain,IDC_IP,offset ipaddr,255
or eax,eax
jz ResolveHost
call lstrcmp,offset unknown,offset ipaddr
or eax,eax
jz ResolveHost
call inet_addr,offset ipaddr
mov cip,eax
call gethostbyaddr,offset cip,4,2
mov ebx,IDC_HOSTNAME
or eax,eax
jz Unresolvable
mov eax,
or eax,eax
jz Unresolvable
call SetDlgItemTextA,hMain,IDC_HOSTNAME,eax
jmp eResolve
Unresolvable:
call SetDlgItemTextA,hMain,ebx,offset unknown
jmp eResolve
ResolveHost:
call GetDlgItemTextA,hMain,IDC_HOSTNAME,offset hostname,255
or eax,eax
jz eResolve
call lstrcmp,offset unknown,offset hostname
or eax,eax
jz eResolve
call gethostbyname,offset hostname
mov ebx,IDC_IP
or eax,eax
jz Unresolvable
mov eax,
mov eax,
mov eax,
call inet_ntoa,eax
call SetDlgItemTextA,hMain,IDC_IP,eax
eResolve:
popad
jmp WEndProcessed
init:
mov eax,hwnd
mov hMain,eax
call LoadIconA,hInst,IDI_ICON1
push eax
call SendMessageA,hMain,WM_SETICON,ICON_SMALL,eax
pop eax
call SendMessageA,hMain,WM_SETICON,ICON_BIG,eax
jmp WEndUnprocessed
close:
call WSACleanup
call PostQuitMessage,0
WEndProcessed:
xor eax,eax
inc eax
ret

WndProc endp
end start
ends


made in NaGoA
Posted on 2001-10-22 22:51:21 by Nguga
Thanks, but that doesnt help at all really.
Posted on 2001-10-22 23:02:54 by ChimpFace9000
ChimpFace9000,

There used to be a lot of TASM code around a few years ago but it has ben effectively bypassed by the power and convenience of MASM. Its been a long time since I had TASM installed but there was a win32 asm example in it that ran OK if a bit larger than the equivelant MASM EXE file.

There used to be a tutorial by _masta_ on Iczelion's site but I don't know if its still there. Perhaps some of the guy who are members have some old TASM code around for you to play with.

Good luck with it.

hutch@pbq.com.au
Posted on 2001-10-23 00:14:14 by hutch--
Posted on 2001-10-23 01:56:41 by Hiroshimator
I still use TASM to make windows asm apps
(actually HE is done with TASM :) )

so ask me by email and i will send you instructions on how to build win32 apps with Tasm (tips and tricks), also there is a WAP32 example inside TASM ;)

if you are a beginner and you do not need TASM (like i do need it because of compiling speed and/or writting apps for other OS's = not Windows) you should use MASM.

Masm works better in windows, after all its designed for it :)
Posted on 2001-10-23 12:38:27 by BogdanOntanu