That is the question.
I've been reading AoA and learning using HLA under the impression that I would eventually be learning straight up assembly. Now I'm beginning to wonder if that is that case at all. I still value the reading I've done...I've no doubt that the concepts will transfer quite nicely to pure assembly...but I'm considering moving to something else. Obviously, the general consensus here seems to be to use MASM(32). It might seem silly to ask, but how should I go about getting started? A book maybe? I haven't been able to find much on learning to use MASM that isn't extremely old.
However, the main question here is whether I should continue with HLA (I'm 20% through the book) or move on before I get too caught up in it.
Thank you!
Hello, well of course learning is all personal taste. Given unlimited time, it would be beneficial to learn AoA first, just as it would be to learn any other programming methodology, as each one expands our perspective, knowledge, and understanding. However I would say that if you don't plan on USING AoA, or are only studying it to learn MASM syntax, then this is the longer path to assembler nirvana.
Some people can teach themselves, and some cannot. If you cannot, then I could suggest Kip Irvine's book at http://kipirvine.com/asm/ -- apparently he teaches a course also. Every semester we see various questions from his students. (Usually because they are lazy and don't want to think for themselves!) :P
If you are the type that can learn on your own, then there are only three things needed to learn MASM32:
1. The MASM32 package: http://masm32.com/
2. The URL to Iczelion's Win32 tutorials: http://win32assembly.online.fr/tutorials.html
3. The ability to open the \masm32\help\*.CHM help files.
In those help files is mission-critical information: they must be referenced; print them out if need-be. Then it is just a matter of following the beginner-to-intermediate Iczelion tutorials to learn the majority of assembly programming. For any specific questions, the Search box here (top-left) probably has the answer.
Welcome aboard! :U
In all my years of using forums (good and bad), that's probably the most straightforward and informative post that has been directed to me. Thank you.
I don't think I'm learning HLA specifically to learn MASM syntax, but when using it, I fell more like I'm programming in C++ all over again than in a new language. I have more questions, but I'll wait to see if some (most [all?]) are answered as I learn.
Edit: I do actually have a question. You mentioned that "Given unlimited time, it would be beneficial to learn AoA first." I forgot to ask why.
Quote from: Jorrj on January 22, 2009, 11:42:05 PM
..."Given unlimited time, it would be beneficial to learn AoA first." I forgot to ask why...
Hi there. Randall Hyde has spent a great deal of time creating AoA, with the intention that it be a "middle-ground" between high-level languages and assembler. While debatable, his reasoning is that some people would rather learn a higher-level assembler, and that it may be more readily adopted by those with existing HLL experience.
His website does a better job of explaining this than I can, please see:
http://webster.cs.ucr.edu/AsmTools/HLA/index.html
Regards,
Mark
Jorrj ,
In my opinion, HLA is not assembly language, HLA is a high-level language.
The original book (http://www.arl.wustl.edu/~lockwood/class/cs306/books/artofasm/toc.html) 'The Art of Assembly Language' by Randall Hyde (1996) was about assembly language and MASM and was a very good book on the subject. The later book (http://webster.cs.ucr.edu/AoA/Windows/HTML/AoATOC.html) of the same name and by the same author (2003) is all about HLA. I think using the title 'The Art of Assembly Language' for the later book is very misleading. How many people have bought the book thinking it was about assembly language, only to find out it's about programming with HLA?
There is nothing wrong with HLA, but it's not assembly language.
Hi Jorri,
I am new to 32-bit code, myself. I looked at the AoA stuff also, including HLA. From what I could see, HLA looked like something that might be great for the right group of students. I think if someone is totally new to programming, it would be a good place to start, if they selected assembly language. And, I think that was the intention of HLA, to begin with; To get beginners up and running without having to learn all the information needed to write assembly language. I am experienced with 16-bit assembly language, and am (trying) making the transition to 32-bit. For me, I thought the HLA was an unneccessary excursion from my real goal.
You and I are in similar circumstances, with one big difference. I am experienced with assembly language, in general. You are experienced with C. If you can learn the raw assembly instructions and processor architecture without going the HLA route, you may be better off, in the long run. Your C experience already has you primed with many of the basic foundations needed to write software.
- Dave
HLA is a true assembler. It allows you to write higher level constructs through macros but you DON'T have to. You can write the lowest level assembly if you wanted to.
HLA also works for windows, linux, freebsd and MacOS. And another advantage is that HLA can translate your code to MASM, TASM, NASM, FASM and I forgot what else, which is cool if you want to examine their syntax.
HLA was designed as a tool to teach you Assembly but is no less powerful than MASM. You can't go wrong with HLA, and you can very easily switch to MASM or any other assembler later.
Just take a look at some HLA proggies and at Iczelion's tutorials. What seems better and more natural to you ?
There is a HLA subforum here, take a look there and around the main masm sections for samples of code. There are also other assemblers, like goasm, but they aren't exactly for beginners.
Personally, I think all asm beginners should start with masm, period. After a few weeks/months you can look at other stuff, knowing what you want/need ...
(http://www.quickersoft.com/pictures/offtopic.gif)
I have to ask. I have been on occasion hearing the phrase "Pure Assembly" and I must confess I don't understand that terms use. What is pure assembly? Back when I did this stuff for a living we called it "Assembly Language". There was never anything "pure" about it. What is this pure? What does that mean, pure assembly?
Everyone has a different notion of asm purity. For me, it's that I want my source to look "kinda" close to the actual (dis)assembly. I debug my exes ALL the time, it's cool to see stuff and recognize what it is. The main thing is to use as much winAPI as possible, when possible.
I love simple HLL structs, especially runtime conditionals, because testing and jumping to labels screwes up my source and my brain. One of these days I may drop dead in front of goasm between a "@" and a ":", but I can't go back to masm's red tape. :green2
Also, using the msvcrt library of masm was useful to me in some occasions, that's cool, too.
P.S.: I like Intel's syntax :bg
Quote from: Bill Cravener on February 23, 2010, 03:04:05 PM
What is pure assembly?
.686p
.model flat, stdcall
option casemap :none
externdef _imp__DispatchMessageA@4:PTR pr1
m2wp equ <_imp__DispatchMessageA@4>
externdef _imp__GetMessageA@16:PTR pr4
gms equ <_imp__GetMessageA@16>
externdef _imp__DefWindowProcA@16:PTR pr4
dpro equ <_imp__DefWindowProcA@16>
externdef _imp__PostQuitMessage@4:PTR pr1
pqm equ <_imp__PostQuitMessage@4>
externdef _imp__RegisterClassExA@4:PTR pr1
scln equ <_imp__RegisterClassExA@4>
externdef _imp__ShowWindow@8:PTR pr2
wshw equ <_imp__ShowWindow@8>
externdef _imp__LoadCursorA@8:PTR pr2
lsc equ <_imp__LoadCursorA@8>
externdef _imp__CreateWindowExA@48:PTR pr12
crwe equ <_imp__CreateWindowExA@48>
includelib \masm32\lib\user32.lib
.code
ims db "Slick Huh ?", 0
pcl dd ims
slick_huh:
push ebp
mov ebp, esp
sub esp, 96
push 32512
xor edi, edi
push edi
mov esi, 4194304
mov ebx, pcl
call lsc
mov DWORD PTR [ebp-96], 48
mov DWORD PTR [ebp-92], 3
mov DWORD PTR [ebp-88], OFFSET wpep
mov DWORD PTR [ebp-84], edi
mov DWORD PTR [ebp-80], edi
mov DWORD PTR [ebp-76], esi
mov DWORD PTR [ebp-72], edi
mov DWORD PTR [ebp-68], eax
mov DWORD PTR [ebp-64], 10h
mov DWORD PTR [ebp-60], edi
mov DWORD PTR [ebp-56], ebx
mov DWORD PTR [ebp-52], edi
lea eax, [ebp-96]
push eax
call scln
mov ecx, -2147483648
push 1
push edi
push esi
push edi
push edi
push edi
push ecx
push edi
push ecx
push 13565952
push ebx
push ebx
push edi
call crwe
push eax
call wshw
lea ebx, [ebp-48]
push edi
push edi
push edi
push ebx
jmp mlep
@@: push edi
push edi
push edi
push ebx
push ebx
call m2wp
mlep: call gms
test al, al
jnz @B
leave
retn
wpep: cmp DWORD PTR [esp+8], 2
jne @F
push 0
call pqm
@@: jmp dpro
end slick_huh
\masm32\examples\exampl10\slickhuh\slickhuh.asm
If you want it purer than that, you'll have to use the db xx, xx, xx syntax.
Me personally I stick to pure
Massembly
I am not sure as to why this thread has come to life after so long or that the Campus is the place for later comments but to try and do Randy Hyde some justice here, his own work with HLA is something akin to an extended macro interface to a variety of assemblers for different platforms. Now while it is not classic x86 Intel assembler, it is an unusual tool that does unusual things and the general drift is the output has a reasonably good mapping to the input so its not just another compiler.
JJ,
I am not sure if that example qualifies as the real thing[tm] and it may be too high level for real men[tm] as it uses mnemonics instead of direct opcodes in hex but then there are few of us left. :green2
HLA is a great way for students to get going :U
JJ - all a matter of interpretation, i guess
to me, "pure assembler" would have no API calls :P
you'd be hard-pressed to write a program that does something
by that definition, BIOS code is the only "pure assembler" in PCs
I tried to use HLA myself. The bright side is that the syntax is easier to read than the asm syntax. My problem was that I had to learn another syntax. I prefer to learn the syntax that's as close to the machine code as possible, simply because I'd like as few as possible layers between my code and the machine code.
Quote from: dedndave on February 23, 2010, 05:36:11 PM
to me, "pure assembler" would have no API calls :P
Exactly - that's why I prefer pure Massembler
tm :green
What ? Integrated operating system functions don't count as impurities. :naughty:
Quote from: BlackVortex on February 24, 2010, 06:20:15 AM
What ? Integrated operating system functions don't count as impurities. :naughty:
whats your point? its an assembler with a library of procedures, whats 'impure' about that?
edit-
oh right. i see what your saying :wink i'm pretty sure daves comment about api calls wasn't mean't to be taken seriously :P
Quote from: Sergiu FUNIERU on February 23, 2010, 06:39:42 PM
I tried to use HLA myself. The bright side is that the syntax is easier to read than the asm syntax. My problem was that I had to learn another syntax. I prefer to learn the syntax that's as close to the machine code as possible, simply because I'd like as few as possible layers between my code and the machine code.
Couldn't put it better!
It's why I moved to assembler on the x86. I was fed up with "How does C++ know that? How does C++ do that? WTF??" so I gave up after much trying and wasting time figuring out where everything came from. HANDLE, LPSTR etc.. just finished me off when I discovered they were all the same type - a DWORD. It was too much - what is wrong with using the actual type? Equates are about the only thing that made sense, but then what is wrong with using the actual value and a quick comment?
Best regards,
Robin.
:P
Robin,
Sounds like you have already been converted. :U
Quote from: jj2007\masm32\examples\exampl10\slickhuh\slickhuh.asm
What's with using [ebp] and leave? RealASMers uses [esp] and count what's pushed.
Nothing better than seeing
push eax
push [esp+16]
push [esp+16]
call WindowsAPI
leave = good :P
sometimes, you want to exit a routine from different points in the code
leave can save you a lot of balancing code
i don't always use it, but it seems to work well for more complex routines
leave = ebp -> that thing like 'enter x,y' that was such a good idea.
Isn't leave a slow instruction?
x86 has a lack of registers, having ebp available is *A Good Thing*.
x64 has more and is more fun :bg
ymmv,imho,ime,etc.
enter is the slow one
leave is actually pretty fast (and small)
i don't use enter :bg
in my ling long kai fang routines, i use EBP as a stack frame base pointer throughout most of the routine
but for the base conversion loop, i push/pop it and use it as a general register
during the loop, i don't need to access the stack frame
Quote from: dedndave on February 25, 2010, 11:22:29 AM
i don't use enter :bg
Me neither. I always use invoke, which results in
push ebp
mov ebp, esp
add esp, nn
I wonder if old versions of Masm use enter...?
Quote from: jj2007 on February 25, 2010, 03:46:40 PM
Quote from: dedndave on February 25, 2010, 11:22:29 AM
i don't use enter :bg
Me neither. I always use invoke, which results in
push ebp
mov ebp, esp
add esp, nn
I wonder if old versions of Masm use enter...?
in the prologue it should be sub esp,nn for reserving the space for local vars on the stack.
Quote from: brethren on February 25, 2010, 04:59:29 PM
in the prologue it should be sub esp,nn for reserving the space for local vars on the stack.
Masm uses add esp, -offset
JWasm uses sub esp, offset
The former saves some bytes if the required # of bytes is exactly 128
include \masm32\include\masm32rt.inc
MyTest PROTO: DWORD, :DWORD
.code
AppName db "Masm32 is great!", 0
Hello db "A message:", 0
start:
invoke MyTest, offset AppName, addr Hello
exit
MyTest proc arg1:DWORD, arg2:DWORD
LOCAL locbuf[128]:BYTE
MsgBox 0, arg1, arg2, MB_OK
ret
MyTest endp
end start
Masm
00401033 /$ 55 push ebp
00401034 |. 8BEC mov ebp, esp
00401036 |. 83C4 80 add esp, -80
JWasm
00401033 /$ 55 push ebp
00401034 |. 8BEC mov ebp, esp
00401036 |. 81EC 80000000 sub esp, 80
not very many procs have 32 dword parms (thank goodness)