:confused:I've been trying to find a place to learn assembly for a week now. ALL I NEED IS A WORKING TUTORIAL!!!
Don't flame me, I don't mean to say that there's any shortage of resources, or that they don't work. They just all seem to be geared toward MASM32 or TASM. I've decided to use FASM because its small and simple, and the extremely cool MenuetOS is programmed in it.

***********PLEASE, you people who hang out in the "FASM" area of the forums, don't tell me this was a bad decision.

If ANYONE can point me to a basic assembly tutorial which will ACTUALLY BUILD in FASM, i would be VERY grateful

and yes, I said basic tutorial, not an Iczelion Win32 tutorial. Yeah, yeah, I know this is a Win32ASM forum, but this is the forum that the FASM site pointed me to.

again, I'm looking for something like Hello World with explanation (and hopefully, if it's not too much to ask, a lot more from there)
Posted on 2003-04-30 20:24:39 by KaS_m
You diden't say what OS
for windows there are some examples in the distro of fasm
look in the zip file fasm came in
for linux goto http://linuxassembly.org
If you are a compleate newibe to assembly under linux
get a handel on assembly useing nasm once you understand what is going on with assembly then you will understand how to use fasm on linux

for freebsd linuxassembly is also a good place to start

good luck!
Posted on 2003-04-30 21:12:55 by rob.rice
sorry for not mentioning it, i'm trying to use FASM in windows. --(I do have several distros of linux, but none currently installed because i reformatted my linux partitions before trying to install Gentoo)
i've already looked at the examples, and they're great and all, but for someone coming from C++ and even things as high-level as Java (like me), they're somewhat incomprehensible. I am a COMPLETE newbie to ASM, with only a vague idea of things called registers, etc. which I have gathered from reading the intros of several tutorials whose code would not build under FASM
if you (or anyone else who checks this out) really think i should use nasm to learn, then i guess i will. but i'd LOVE it if anyone could show me an online beginners tutorial specifically geared towards FASM. I know they exist, because Google found me a site that claimed to have one but was "down for updating".

This thread is still open, people please post if you know one.
Posted on 2003-04-30 21:33:39 by KaS_m
This might me of some help: http://www.asmcommunity.net/board/index.php?topic=11394

My 2nd to last post there should help distinguish API's from the Language and Tool.

To get any fasm examples to work, you will either have to set the include environment variable or patch the code to point to your include directory. I've also heard that the include files are not always compatible from different versions of fasm.

I like fasm (the assembler; I don't use the editor) because of the control it gives me. It lets me do odd things like roll a FAT16 file system image.

There are some cons to using fasm, such as the lack of prototypes (which could be used for parameter checking).
Posted on 2003-05-01 01:59:58 by eet_1024
Posted on 2003-05-01 02:18:32 by Vortex
Here's a modified version of the tutorial which you posted a link to Vortex... The modifications are small, but this is first and foremost done to support the include-library in the newest versions of FASM ;)
Posted on 2003-05-01 02:47:23 by Tommy
I really appreciate you guys trying to help me, but i find it very frustrating that the thread you pointed me to, eet_1024, demonstrates Hello World in Windows as another MessageBox slung at me via the Win32 API. I've done the API in C++, and what i'm looking for is a tutorial that will provide a simple intro to asm, explaining registers, etc. and working in fasm. I respect the fact that many of you think i should figure stuff out for myself. I'm very happy to experiment with things on my own, but no amount of experimentation is going to tell me why fasm doesn't like the line:
.model small
when everyhting seems to indicate that that's assembly. fasm obviously just does it differently, but i need to know what the difference is. Here's an entire Hello World example that i've found online, please tell me everything that needs to be changed to make it fasm syntax:

.model small
.stack 100h

.data
hello_message db 'Hello, World!',0dh,0ah,'$'

.code
main proc
mov ax,@data
mov ds,ax

mov ah,9
mov dx,offset hello_message
int 21h

mov ax,4C00h
int 21h
main endp
end main

i'm not dumb, and i understand what a lot of this is SUPPOSED to do. for example, i get that int 21h is tossing the info in the ax register up to DOS, and that the fact that the high part contains 9 will make DOS print the contents of message, which is pointed to in dx (hope that's right) to the screen. however, fasm wont give me a chance to verify this if i cant get past the first declaration of a section of the program.

oh, and eet_1024, i figured out the include thing on my own already, but thanx anyway.

oh, also, Tommy and Vortex, the example progs you gave me would be great, if i was trying to learn to write ASM progs for the Win32 API. Once again, i'm not. Not until i've mastered the basics.

it would be great if someone had a big fat glossary type thing on converting the syntax that all the basic learning tuts use (masm32, tasm, sometimes nasm, NEVER fasm) to fasm syntax. That way, i could get past this and actually LEARN. I think we'll all agree it's hard to learn a new language without being able to build Hello World.
Posted on 2003-05-01 14:31:28 by KaS_m
What you want is not a fasm tutorial, it's the basics of assembly on x86 (I think) :)

http://www.madwizard.org/dl.php?file=tutors.win32asm - the resident madwizard has some pretty nice stuff.

Once you feel comfortable with that, http://developer.intel.com/design/pentium4/manuals/ has the really hardcore information.

As for the "model" stuff etc, it's masm specific - fasm is rather pure in syntax. Haven't used it much myself, but it's been a really good tool for the stuff where I've needed it.

I see the example you've posted is for 16bit dos... especially if you're new to assembly, 32bit is a nicer place to start - you won't have to bother about segments/offsets and all that, you can apply your existing knowledge of the win32 api, and always return to 16bit if you feel like it :)
Posted on 2003-05-01 14:43:22 by f0dder
Here's what it equals in FASM. Sorry, I don't have time to explain now...

format MZ
entry main:start
stack 100h

segment text
hello_message db 'Hello World!',0Dh,0Ah,24h

segment main
start:
mov ax,text
mov ds,ax

mov ah,09h
mov dx,hello_message
int 21h

mov ax,4C00h
int 21h

Cheers!
Posted on 2003-05-01 14:46:58 by Tommy
f0dder, thanks a lot for recommending the API to me in a new light. I can see the sense in that, and i'll write 32 bit for Win32 for now. However, i want to not just know how to do API stuff. I want to UNDERSTAND assembly, as in all the registers, mov and stuff like it (don't know the name for those).

f0dder, please answer one question for me. The madwizard tut you directed me to looks great, very detailed, but it's written for masm32. should i get masm32 to learn it, despite the fact that i would prefer to learn fasm syntax? or is there some equivalent to this that is meant for fasm, and doesn't just say ".model" something at the top and not work in fasm?
i really would prefer to use fasm, partly because its an under development, evolving assembler and not an old one, and partly because great stuff like MenuetOS is written in it. (maybe someday i can contribute!)

and Tommy, THANKS FOR FINALLY SHOWING ME THIS! maybe this will help me translate all the basic tuts out there to fasm myself.
Posted on 2003-05-01 15:06:52 by KaS_m
Oops - the direct download URL I gave you doesn't work - you'll have to go to www.madwizard.org, tutorials, win32asm basic tutorials / htmlhelp version.

KaS, there's very good sense in learning how to do assembly programming and not just how to do API coding - frankly, you can get pretty much stuff done with "win32asm" without really knowing assembly at all. Just look at how few registers and mnemonics/instructions ("mov and stuff like it") it takes to get a dialog up and running :).

It does make sense, however, to do your assembly coding in the 32bit real, and windows isn't a bad choice either. There's a lot of stuff to take advantage of... good documentation, good integrated development tools (or plain text editors if you prefer), and good tools (masm, fasm, asmedit, radasm, masmed).

the "win32asm basic tutorials" has _some_ masm specific stuff in it iirc, but it's not much, and Thomas does a good job at describing "the raw stuff". If you want the _really_ raw stuff, and _all_ of it, go for the intel pentium4 manuals. It can be a bit overwhelming at first, though - pretty dry techy stuff. Very interesting though.

As for fasm/masm... there's more stuff to get you started and hold your hand for masm, but if you can get some simple fasm stuff running, you should be quickly be able to abstract from the masm-specific stuff out there. Do yourself a favour - no matter which assembler you go for, write a template.asm file to use as a starting point. Then, find a good text editor that will let you use template files. I personally use editplus, it has okay syntax highlighting and stuff. Other good editors would be textpad and ultraedit. All of them have syntax highlighting and allow you to set up external tools (ie, assemble+link with a couple of keystrokes).

Perhaps you'd want to start with masm for the first couple weeks, usually people get "up and running" faster. It has high-level stuff, but you don't necessarily have to use that (a good exercise would be using it, and then writing the same with the simple instructions). You can switch to fasm when you feel you're ready.

Another good thing with fasm is that it's actually legal to use :). Microsofts EULA for masm from the DDK states you can only use it for windows development, and iirc the one from the XP DDK even states you can only use it for drivers...

Oh, and when you're ready for it, fasm has some pretty hefty macro support. Plus it's open-source.
Posted on 2003-05-01 15:25:17 by f0dder
if you don't mind working under DOS there ia a shareware assembler called a86
it has a dissasembler with single stepping that will let you watch the code being run
and let you see the result of what is going on
Posted on 2003-05-01 18:25:35 by rob.rice
KaS_m,

Not much to say about fasm. I like it the most of all the assembler I have tried. If I remember right fasm sysntax is like tasm ideal mode with some nasm stuff thrown in.

If you need any help understanding assembly/fasm you can catch me on AIM(AOL Instant Messanger) under jinuq or email me at jinuq@asmcode.com and will help as best as I can.
Posted on 2003-05-02 00:41:33 by jInuQ
You could create a console app with only 1 API AllocConsole. Then make code, and step thru it with a debugger tosee what happens and how the regs work.
Posted on 2003-05-02 01:31:15 by ThoughtCriminal
You don't even need AllocConsole if you're doing console mode apps - windows will allocate one for you automatically if you have the right image type set.
Posted on 2003-05-02 01:54:35 by f0dder
The following code is a Hello, World! app for DOS 16 bit which Tommy kindly gave to me.

format MZ
entry main:start
stack 100h

segment text
hello_message db 'Hello World!',0Dh,0Ah,24h ; these three hex numbers are my question

segment main
start:
mov ax,text
mov ds,ax

mov ah,09h
mov dx,hello_message
int 21h

mov ax,4C00h
int 21h

Using what i see here and some arithmetic opcodes i learned about, i decided to make a simple temperature converter as a first exercise. However, as soon as i created a new source file and got to the "text" segment as above, i realized i couldn't change the message, because of something involving the three hexadecimal numbers after it above. I know they are necessary, and some kind of corruption of the text occurs without them, but what exactly do they do and how can i use them to create any text data i want? Sorry I couldn't find the answer in a tut, don't mean to bug you guys with dumb newb questions.

Also, as a C++ person used to variables, the whole put it into ax, then put it in something else immediately thing seems inefficient to me. I know this is necessary, but if someone could explain to me why i'd feel better about it.
Posted on 2003-05-02 21:36:03 by KaS_m
0Dh,0Ah is the new line for dos/windows.
The 24h is the $ which if I remember right is needed in dos.

The API's use C style null terminated strings:

Attached is a fasm skeleton source.
Posted on 2003-05-03 00:33:23 by jInuQ
i'm guessing that "db" means data buffer. correct me if i'm wrong.

if so, how do i remove specific pieces of a db and append new ones. for example, when i call int 21h with 0Ah in ah, to read a string from the command line, i get it in a form that needs some additional formatting. it has a small number at the beginning that is necessary for this function, and an ASCII code for the "enter" key (13) at the end, both of which should be removed. Also, if i wanted to output it to the command line, i would need to add a $. How do i do these things?

also, i'm guessing that if i input some number with this function it will be stored as its ASCII code. How do i convert that to a real number so i can do math and then back again? (preferably a floating-point number for accuracy)

i hate to keep asking people for the answer to every little thing, but i just can't find any of this specific info in any online resources.
Posted on 2003-05-03 11:15:54 by KaS_m
By the way, "db" means "define byte". A text string is an array of bytes, so it has to be defined that way. To define a doubleword, you define it as "dd".
Posted on 2003-05-03 13:19:19 by president
thanx pres... i was pretty far off

but whatever it means, when i do what i said to get a string from the command line, i end up with the same problem. here's the code...
mov ah, 0Ah
mov dx, orig_temp
int 21h

and the string i get with this needs to have the stuff removed i mentioned in my last post

also, anyone who can answer my (very) basic question about how to convert ASCII numbers to real ones (do I need to just explicitly define them all with an ASCII chart??) would go a long way towards making me able to write a (kinda) functional program in assembly
Posted on 2003-05-03 13:31:23 by KaS_m