flat assembler
Message board for the users of flat assembler.
Index
> Main > Where to start? Goto page 1, 2, 3, 4, 5, 6, 7 Next |
Author |
|
AsmGuru62 26 Mar 2012, 18:38
FASM has some code in EXAMPLES folder.
But, generally, just start making some small program and ask questions here as needed. |
|||
26 Mar 2012, 18:38 |
|
dancho 26 Mar 2012, 19:09
ok , start from here,
basic fasm console program : Code: format PE console 5.0 entry cmain include 'win32axp.inc' section '.text' code readable executable cmain: invoke ExitProcess,0 section '.data' data readable writeable nop section '.idata' import data readable library kernel32,'kernel32.dll' include 'api\kernel32.inc' write this snipet in fasmw , compile it , read fasm.pdf , all code from here ( except ExitProcess, dont worry about it atm ) is explained there ... lesson 0. print 'Hello World' message on the console ; little hint /* printf function from msvcrt.dll */ then for lesson 1. add 2 numbers and print it on the console Im sure others forum members will glady give you some more assignments |
|||
26 Mar 2012, 19:09 |
|
typedef 26 Mar 2012, 21:50
lesson 3 create a stealthy key logger.
Just kidding. First I'd recommend learning calling conventions and pointers/structures and addressing. Once you know those you can move on to different APIs. |
|||
26 Mar 2012, 21:50 |
|
Stephen 27 Mar 2012, 03:52
Inagawa wrote: how to learn FASM? Windows, Mac, Linux, Dos, Monuet, Dex or things that don't use an OS? What kinds of things do you want to do. Learn some stuff and try writing a few programs that do that. Check out some programs that include source code. I would say look for commented ones, but the uncommented ones are sometimes better. Probably because you have to look more and harder. Inagawa wrote: "The Art of Assembly Language" (learning HLA is not really my thing) I don't think I ever directly used any thing from there. I've gone through the source code and it's very interesting to see how they do things. He also did the ucr assembly library, good stuff but probably totally dated at this point. Inagawa wrote: I will probably be able to piece together basic assembly instructions, but where am I supposed to learn FASM specific things? Take some FASM programs and change some things to get different results. Inagawa wrote: I do not know how the FASM program structure should look, what is good practice, what isn't - etc. That gets down into what kind of programmer you are looking to become. If you are on a team or trying to write programs that are part of something else, it matters.You need to be able to work with what others are doing and they need to be able to work with your stuff. If you are writing stuff on your own or with some friends, rule one: fast, rule two: small. Actually rule 2 is no longer the big deal it use to be. Although when your company wants to sell a million items and the controller with 5k of memory costs fifty cents more then the one with 2k, it still matters. If you need to learn structure take some classes. Look at the source code to a bunch of programs, most of the ones not put out by big companies break rules or only try to follow rule one, make it work fast. _________________ !31337 |
|||
27 Mar 2012, 03:52 |
|
majidkamali1370 27 Mar 2012, 09:30
For low level programming "Art of assembly" is a great book.
Otherwise, if you want to do windows programming, there are lots of masm examples out there. You can convert them to fasm syntax. This is a good programming practice. |
|||
27 Mar 2012, 09:30 |
|
Inagawa 27 Mar 2012, 11:48
Hi there, thanks a lot for all the advice! I will study fasm.pdf and try to use the things in practice with what dancho posted here.
Stephen: Well, I am interested mainly in windows. My ultimate goal is to make a very basic compiler. That seems to be a long way from happening, though. |
|||
27 Mar 2012, 11:48 |
|
smiddy 27 Mar 2012, 13:27
Inagawa wrote: Stephen: Well, I am interested mainly in windows. My ultimate goal is to make a very basic compiler. That seems to be a long way from happening, though. |
|||
27 Mar 2012, 13:27 |
|
Stephen 28 Mar 2012, 03:43
Windows is probably a bit different then you think. You can do a bunch of math and shift a lot of things around in memory, but for the most part when ever you want something to happen your program has to send a request to windows to do it. How they decided to do that is you push all the data to the stack and then make an api call. The hello world program is a good example. You get all the data in place and then call windows and request it open a window of the type you want and put the text in it. That's a good place to start. With that program you can try out opening all kinds of windows with all kinds of different options. If you want to program windows, besides learning asm, you'll need to learn a lot about the windows api's, because that is the way they want you to request windows do things.
|
|||
28 Mar 2012, 03:43 |
|
bubach 28 Mar 2012, 13:13
IMO you should start with some .com files, using windows 16-bit dos compatibility for easy learning of fasm and assembly in general. when you're more comfortable with the assembly way of doing things it will be easier to move on to windows gui programming.
|
|||
28 Mar 2012, 13:13 |
|
Inagawa 28 Mar 2012, 13:39
Well, I've yet to finish the Fasm.pdf
|
|||
28 Mar 2012, 13:39 |
|
ProphetOfDoom 28 Mar 2012, 21:13
Hullo Inagawa,
I learned 32 bit assembly from the book here: http://www.drpaulcarter.com/pcasm/ It covers, if anything, more than you need to know. One area that is lacking is the coverage of the FPU instructions for which you can look here: http://www.website.masmforum.com/tutorials/fptute/ The latter tutorial isn't very friendly though, and makes stuff look harder than it actually is. Once you understand 32-bit assembly you can make the jump to 64-bit with this brief guide: http://www.x86-64.org/documentation/assembly.html and this document: www.agner.org/optimize/calling_conventions.pdf |
|||
28 Mar 2012, 21:13 |
|
edfed 28 Mar 2012, 22:27
my advice is to code the hello world in the system coding style you want to code for (linux, windows, dos, boot, etc....)
means, write step by step every little boring code and you'll get the instinct, it helps to code faster. |
|||
28 Mar 2012, 22:27 |
|
LostCoder 29 Mar 2012, 11:03
A lot of compilers has switch to generate assembly listing. You can write small programs in high level languages, generate it's listing and see what and how compiler does.
|
|||
29 Mar 2012, 11:03 |
|
Inagawa 29 Mar 2012, 12:51
Thanks a lot to all you guys for the suggestions. It is so calming to know that there is a strong community around FASM
I will check it out, Prophet; I'll get back to you once I do. |
|||
29 Mar 2012, 12:51 |
|
Inagawa 29 Mar 2012, 16:27
Code: format PE console 5.0 entry start include 'win32axp.inc' ;============================================================================ section '.data' data readable writeable __promptMsg_First db 'Input a number: ', 0 __promptMsg_Repeat db 'Input another number: ', 0 __feedbackMsg_Higher db 'Try higher: ', 0 __feedbackMsg_Lower db 'Try lower: ', 0 ;============================================================================ section '.bss' data readable writeable __inputVal_1 rd 1 __inputVal_2 rd 1 ;============================================================================ section '.text' code readable executable start: entry 0, 0 pusha ccall [getchar], eax mov __inputVal_1, eax ccall [printf], __inputVal_1 ccall [getchar] invoke ExitProcess, 0 ;============================================================================ section '.idata' import data readable library kernel32,'kernel32.dll',\ user32, 'user32.dll',\ msvcrt,'msvcrt.dll' include 'api\kernel32.inc' include 'api\user32.inc' import msvcrt,printf, 'printf',\ getchar,'_fgetchar' What am I doing wrong? I fail to see the problem.. The "undefined symbol start" error whenever anything is wrong is really unhelpful in solving problems |
|||
29 Mar 2012, 16:27 |
|
Tomasz Grysztar 29 Mar 2012, 17:05
Inagawa wrote: What am I doing wrong? I fail to see the problem.. The "undefined symbol start" error whenever anything is wrong is really unhelpful in solving problems |
|||
29 Mar 2012, 17:05 |
|
Inagawa 29 Mar 2012, 17:17
Thanks, it finally says where the problem is. Now I can try to fix it myself.
Edit: Shame on me, forgot the brackets on __inputVal_1 |
|||
29 Mar 2012, 17:17 |
|
Inagawa 30 Mar 2012, 16:20
I hope I can continue to write here with my obnoxious questions.
How do I print numbers with [printf]? It only prints the ASCII equivalent. I have tried all I could think of but nothing helped me |
|||
30 Mar 2012, 16:20 |
|
gunblade 30 Mar 2012, 16:33
printf's syntax is:
printf(format, [param]...); The way you are using it at the moment, is just passing it a string as a "format", which it just prints out.. So.. printf("hello"); would print hello, and printf(__inputVal_1); would print the string in the inputval variable. If you want to print numbers/etc, you need to use the parameters. The "format" string doesnt just need to be text, it can also contain replacable strings, usually using % to specify that it is a special word. Theres a big list of all the available formats.. but lets take "string" first.. printf("%s",__inputVal_1) would be the same as printf(__inputVal_1).. For your numbers, you then have to start using other characters.. so, theres %u for "unsigned integer", which is probably what you want.. printf("%u",5) would print 5 (notice that 5 isnt a string like "5", its just the number), you can then also just pass a variable with a number in it, like: printf("%u",numberVal); You could also pass __inputVal_1 like in the program above, but then it will end up printing the pointer to the string as an unsigned integer. One of the many available pages describing printf's syntax: (with examples at the bottom): http://www.cplusplus.com/reference/clibrary/cstdio/printf/ You would do the same, just call it using ccall [printf],format,parameter,parameter2,parameter3.... I can write up a quick working example if you cant get it working, but would be good for you to write one yourself (just dont forget those brackets again ) |
|||
30 Mar 2012, 16:33 |
|
Goto page 1, 2, 3, 4, 5, 6, 7 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.