Cybrg641
Aug 20th, 2000, 12:17 AM
I have MASM32. It seems to be pretty good. Go to this site (http://members.tripod.com/lordlucifer_/) for compilers and tutorials. By the way, could you send me the code that you used to open/close your cd drive? Thanks.
Paul282
Aug 20th, 2000, 08:28 PM
Try this
http://www.programmingtutorials.com/
damn, I dont know why I didnt ever try that URL before :D
BTW Thanks!
[Edited by denniswrenn on 08-20-2000 at 08:48 PM]
http://burks.bton.ac.uk/burks/language/asm/artofasm/artof001.htm
Paul282
Aug 21st, 2000, 10:56 PM
Yeah, I've been through that one.
I tend to find that you're better of with a book when it comes to ASM. (not that I'm an experienced ASM programmer) I also find that books cover the topic in much more depth and that has been very important to me so far in learning ASM.
I got this book...
http://www.amazon.com/exec/obidos/ASIN/0136603904/o/qid=966912472/sr=2-1/002-3470099-9752032
[Edited by Paul282 on 08-21-2000 at 10:59 PM]
Cybrg641
Aug 22nd, 2000, 04:10 AM
$73.00?!?!?! Jeez!! That's way too much for me!
Paul282
Aug 22nd, 2000, 05:09 AM
I'm always happy to spend money on books. Net tutorials are good but if I buy a book I'm more inclined to sit down and actually learn the topic in depth.
Sort of like an investment in myself, the payback comes when I ask for twice as much in my next job :-)
It's worked well so far anyway, I'm not 30 yet, I didn't even finish school let alone go to college and I earn over US$100k a year in the IT industry!
I have a problem with modesty though :D
V(ery) Basic
Aug 22nd, 2000, 09:34 AM
It shines through like a supernova
Paul282
Aug 22nd, 2000, 09:59 AM
:D
can't even blame alcohol for that comment!
V(ery) Basic
Aug 26th, 2000, 05:15 AM
I'm posting this here, because it's such a petty question it isn't worthy of a new thread:
Could somebody post just a little source code (ASM), because I'm really interested to see what it look like.
Thyroid.
parksie
Aug 26th, 2000, 07:17 AM
From the MASM32 website:
; #########################################################################
.386
.model flat, stdcall
option casemap :none ; case sensitive
; #########################################################################
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
; #########################################################################
;=============
; Local macros
;=============
szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM
m2m MACRO M1, M2
push M2
pop M1
ENDM
return MACRO arg
mov eax, arg
ret
ENDM
;=================
; Local prototypes
;=================
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY PROTO :DWORD,:DWORD
.data
szDisplayName db "Template",0
CommandLine dd 0
hWnd dd 0
hInstance dd 0
.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke GetCommandLine
mov CommandLine, eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
; #########################################################################
WinMain proc hInst :DWORD,
hPrevInst :DWORD,
CmdLine :DWORD,
CmdShow :DWORD
;====================
; Put LOCALs on stack
;====================
LOCAL wc :WNDCLASSEX
LOCAL msg :MSG
LOCAL Wwd :DWORD
LOCAL Wht :DWORD
LOCAL Wtx :DWORD
LOCAL Wty :DWORD
;==================================================
; Fill WNDCLASSEX structure with required variables
;==================================================
mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW \
or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
m2m wc.hInstance, hInst
mov wc.hbrBackground, COLOR_BTNFACE+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, offset szClassName
invoke LoadIcon,hInst,500 ; icon ID
mov wc.hIcon, eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor, eax
mov wc.hIconSm, 0
invoke RegisterClassEx, ADDR wc
;================================
; Centre window at following size
;================================
mov Wwd, 500
mov Wht, 350
invoke GetSystemMetrics,SM_CXSCREEN
invoke TopXY,Wwd,eax
mov Wtx, eax
invoke GetSystemMetrics,SM_CYSCREEN
invoke TopXY,Wht,eax
mov Wty, eax
szText szClassName,"Template_Class"
invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,
ADDR szClassName,
ADDR szDisplayName,
WS_OVERLAPPEDWINDOW,
Wtx,Wty,Wwd,Wht,
NULL,NULL,
hInst,NULL
mov hWnd,eax
invoke LoadMenu,hInst,600 ; menu ID
invoke SetMenu,hWnd,eax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
;===================================
; Loop until PostQuitMessage is sent
;===================================
StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:
return msg.wParam
WinMain endp
; #########################################################################
WndProc proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD
.if uMsg == WM_COMMAND
;======== menu commands ========
.if wParam == 1000
invoke SendMessage,hWin,WM_SYSCOMMAND,SC_CLOSE,NULL
.elseif wParam == 1900
szText TheMsg,"Assembler, Pure & Simple"
invoke MessageBox,hWin,ADDR TheMsg,ADDR szDisplayName,MB_OK
.endif
;====== end menu commands ======
.elseif uMsg == WM_CLOSE
szText TheText,"Please Confirm Exit"
invoke MessageBox,hWin,ADDR TheText,ADDR szDisplayName,MB_YESNO
.if eax == IDNO
return 0
.endif
.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
return 0
.endif
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
WndProc endp
; ########################################################################
TopXY proc wDim:DWORD, sDim:DWORD
shr sDim, 1 ; divide screen dimension by 2
shr wDim, 1 ; divide window dimension by 2
mov eax, wDim ; copy window dimension into eax
sub sDim, eax ; sub half win dimension from half screen dimension
return sDim
TopXY endp
; ########################################################################
end start
V(ery) Basic
Aug 26th, 2000, 10:40 AM
Hmmm. It's not as harsh as I thought it would be.
Thanks, parksie.
parksie
Aug 26th, 2000, 01:33 PM
Having started to learn this morning, I can confidently say that it is definitely not as hard as people say.
V(ery) Basic
Aug 26th, 2000, 03:02 PM
Yeah, I was expecting something where you had to intercept all the mouse messaages and keyboard messages, and you had to create the window yourself and set the pixels yourself. It just seems like a primitive C++, though.
parksie
Aug 26th, 2000, 05:41 PM
Not really. You do need to set up a window procedure and all that, but a basic program in C++ takes up about 25K, and that program I gave assembles into 5K, and uses NO DLLs WHATSOEVER. Also, when doing asm, you can optimise it by hand by method, because there are new, more efficient ways to do certain algorithms.
Paul282
Aug 27th, 2000, 07:26 AM
bit of a reality check though. That's MASM32! which has quite a bit added to make it easier. to actually write your own code you'd need a better understanding of ASM in it's normal form.
Here's hello world
title Hello World Program (hello.asm)
; This program displays "Hello, world!"
.model small
.stack 100h
.data
message db "Hello, world!",0dh,0ah,'$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,9
mov dx,offset message
int 21h
mov ax,4C00h
int 21h
main endp
end main
There is a lot to learn before you can really start. Don't get me wrong, what you learn about CPU's, registers and memory is valuable in any language. But you'd need to know basic ASM syntax before you used MASM32.
You should be able to look at the above code and see it is only using 16 bit registers.
Int 21h is a dos interrupt, but other than that you'd need understanding of the AX, DS and quite a few other register's functions. I've only been in this for a few months and have hardly written anything, but it's fascinating. The commands are one for one based on machine code!
parksie
Aug 27th, 2000, 07:29 AM
Paul - thanks for that, I needed some example code to do this. Why is the string terminated with a '$' not '\0'?
Also, when you write your program, do you need to worry about the register state before or after your program runs?
Darkwraith
Aug 1st, 2003, 05:13 PM
The string is terminated with a '$' because INT 21h function 09h stops displaying characters once a '$' is reached.
I really don't think you have to worry about register states before and after your application runs.