Thread: Jazz 2 Source
View Single Post
JZBlue

JCF Member

Joined: Dec 2001

Posts: 158

JZBlue is doing well so far

Jan 31, 2002, 11:22 AM
JZBlue is offline
Reply With Quote
now suddenly comming back to this I feel slightly suprised
You are teaching me how to code in ASM?!

Why don't you try writing an OS in C? Have you compared a C porgrams size and speed to the same program written in ASM? Size doesn't matter that much anymore though it generally is a little smaller, and speed.. Lol! You can't even compare the speed, asm is hecka faster than anything already out there.

So it's not portable, that's about the only disadvantage along with annoying coding

btw, if anyone wants the source code of JJ2 in assembly, they can IM me on AIM @ SN: Kesshutsu


Here's a better example of the hellow world program in Win32 ASM this time



.386 ; 32-Bit when .386 appears before .MODEL
.MODEL FLAT , STDCALL

include windows.inc
include user32.inc
include kernel32.inc
include gdi32.inc
includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib

.data
ClassName db "SimpleWinClass",0
AppName db "Hello!",0
TestString db "Hello World",0

.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hwnd HWND ?

.code

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR, CmdShow:SDWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG

mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION

mov wc.hIcon,eax
mov wc.hIconSm,0
invoke LoadCursor,NULL,IDC_ARROW

mov wc.hCursor,eax
invoke RegisterClassEx, addr wc

INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT, ;postion
300,100, ;size
NULL,NULL,\
hInst,NULL
mov hwnd,eax


INVOKE ShowWindow, hwnd,SW_SHOWNORMAL
INVOKE UpdateWindow, hwnd

.WHILE TRUE
INVOKE GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
INVOKE TranslateMessage, ADDR msg
INVOKE DispatchMessage, ADDR msg
.ENDW
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hdc:HDC
LOCAL ps:PAINTSTRUCT

mov eax,uMsg
.IF eax==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF eax==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax

invoke TextOut,hdc,0,0,ADDR TestString,(SIZEOF TestString) -1

invoke EndPaint,hWnd, ADDR ps

.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp

start:

invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax

end start

Last edited by JZBlue; Jan 31, 2002 at 11:36 AM.