flat assembler
Message board for the users of flat assembler.
Index
> Main > How to get into assembly programming Goto page 1, 2 Next |
Author |
|
revolution 03 Nov 2019, 11:27
When you download fasm you also get a few example sources. They might help you to get started. Have you seen them? Try to assemble and run them. As least then you can check that you have set everything up correctly.
|
|||
03 Nov 2019, 11:27 |
|
DimonSoft 03 Nov 2019, 11:44
Getting into assembly after C# and Python is like trying to dive with large helium balloons tied to your feet. These languages hide a lot of stuff that goes under the hood and most books just pretend it’s OK for people using these languages to know close to nothing about that stuff (spoiler: they’re absolutely wrong, that’s why most software these days is slow and bloated). C++ doesn’t help much as well.
I’d suggest you to recall every piece of generic information you should have known about computer internals, memory, about how integers, floats and strings are represented in memory, about what actually happens when you build your program. The next step is to know your execution environment and OS: it’s quite hard for a beginner to write something useful absolutely from scratch, and even for an advanced programmer it always makes sense to reuse the things you already have anyway like OS API. After that you’ll have a better feeling of what you can do and more specific questions on how to do particular things. BTW, if you target, say, Windows, writing WinAPI-programs in some HLL for a while might make is easier. Delphi used to make this even easier, but plain C might do the thing as well, except for the thousands of hidden traps of undefined behaviour and language inconsistencies, that are easily understandable but only after you’re OK with low-level programming. Actually, that’s exactly the reason why starting with Python-like languages is generally a one-way road in programming: such languages hide the platform-specific stuff and encourage a newbie to stay completely agnostic of it, which later makes them write inefficient code for no valid reason and generally makes them unable to move “backwards”, back to the basics. |
|||
03 Nov 2019, 11:44 |
|
rc 03 Nov 2019, 12:23
Hello,
thanks for the helpful answers. Yes I've seen the examples and played with them a little bit. Tried to extend them and so on. Yes, that's exactly where I'm at: I've never had to look behind the scenes to see what's going on there. Therefore I'm really stuck now. Seems like that I have to really start from scratch again and learn the very basics of how a computer works. But finding good up to date lectures about this in combination with the low level programming language of your choice (fasm) is hard, as it seems no one is really interested in this anymore. As I played around with the examples, they crashed without any error message. I've set up ollydbg as jit debugger, but this doesn't help that much as I'm still not really understand what caused the crash. Therefore it's really hard to learn from the mistakes when one not really understands what's going on. For example: at work when I'm stuck because of a crash or whatever, I'm stepping through the code with the debugger (visual studio) and it totally makes sense. If not, I just google it, and 95% I find a solution to the problem. Or i ask a college for help, like they ask me when they are stuck. In assembly, the debugging makes no sense and in addition to that I find no good resources online that helps. This is one of the reasons that makes starting assembly programming so hard. At work I have a workflow and I do exactly know what to do when I'm stuck. In assembly however it feels like I have nothing. And posting every little problem that I have here in the forum, so proffesionals in assembly could tell me what is causing the error so I can learn from it does not sound like a good solution as it spams the forum. Last edited by rc on 03 Nov 2019, 12:32; edited 1 time in total |
|||
03 Nov 2019, 12:23 |
|
revolution 03 Nov 2019, 12:31
Post your code. We can help you to find the problem.
|
|||
03 Nov 2019, 12:31 |
|
rc 03 Nov 2019, 12:51
I have no problem in particular at the moment. I would like to know how would you go for finding a problems cause besides debugging. What are your resources, as just typing the problem in google does not really help.
Kind of a guideline of how to structure a project in assembly. Where to learn the basics beyond the type of tutorials: "what are registers, what is the stack" and so on. Kind of a route that I can take to improve. I mean I know what registers are and there purpose and what's the stack. I know how to push/pop stuff from and to the stack, how to use registers and so on. Still I don't really know how to program in assembly. A bit hard to explain. Last edited by rc on 03 Nov 2019, 13:33; edited 1 time in total |
|||
03 Nov 2019, 12:51 |
|
revolution 03 Nov 2019, 13:02
I use a debugger as my primary tool when I have trouble. It gets right down to the precise problem quite quickly. The only time it fails is for logic errors where the code itself is fine but the algorithm (or the implementation of the algorithm) is flawed and I need to look at the higher abstract level to find where things have gone haywire.
However if a debugger is not for you, then another way to follow the progress of the code is to print lots of information to the console. But that is kind of like a poor implementation of a debugger, and it is quite a tedious method. |
|||
03 Nov 2019, 13:02 |
|
rc 03 Nov 2019, 13:18
What debugger do you use? In general, I prefer debuggers over print debugging. What is confusing though is, that unlike in high level languages you don't exactly step through the lines of code you have written. So you end up stepping through the code that the assembler has written out of your code. That's pretty confusing. I mean, that makes sense since you can't step through your macros and stuff line by line as they get converted into assembly as well, but that's confusing: what line in the debugger corresponds to the the line in my code. And also plain assembly code you have written is changed by the assembler due to optimization I guess.
Stepping through the debugger is a bit like: "hum, that's not what I have written, where am I right now.. and what is it doing.. " That might sound pretty silly, but I guess that comes from working with visual studio 10 years, where you can step exactly through every line you have written and how you have written them. |
|||
03 Nov 2019, 13:18 |
|
revolution 03 Nov 2019, 13:30
You can write assembly without any macros. That way in the debugger you will see every line you wrote in the source. For example this simple .com program demo has four lines of code, no macros:
Code: ; fasm example of writing 16-bit COM program org 100h ; code starts at offset 100h use16 ; use 16-bit code display_text = 9 mov ah,display_text mov dx,hello int 21h int 20h hello db 'Hello world!',24h |
|||
03 Nov 2019, 13:30 |
|
rc 03 Nov 2019, 13:40
Yeah that was what I was thinking too: would it make sense to start learning 16 bit assembly on DOS first? I have set up freeDOS on a vm, although I could probably use dosbox as well. Would you suggest me learning 16 bit first?
|
|||
03 Nov 2019, 13:40 |
|
revolution 03 Nov 2019, 13:48
If you are comfortable in DOS then .com programs are probably the most basic you can get. For a debugger in DOS the "Turbo debugger" is good IMO.
|
|||
03 Nov 2019, 13:48 |
|
rc 03 Nov 2019, 14:04
I grew up during the end phase of dos where win 95 was coming. So I used dos in my childhood. Then I will probably start with fasm on DOS first. I will try the Turbo debugger. Thanks a lot for the help. Although this might not be the last time here me asking for help.
|
|||
03 Nov 2019, 14:04 |
|
AsmGuru62 03 Nov 2019, 16:04
Hello rc and Welcome to the forum!
You raise good questions. There is not much information on FASM coding if you Google for it. As already mentioned, you can try the code samples provided in FASM download, but these are limited. You are asking about using registers and arrays - I believe the FASM manual, which you can find at same page as where FASM download is, can provide a bit of the register manipulation as well, but I think no arrays there. Also, please take a look at this tutorial: https://blog.brakmic.com/intro-to-x86-assembly-with-fasm/ It is a start, but I think if you want arrays - you need to dig deeper. By the way: (I am going to get self-promotional here) I had a web site once where you can find the IDE for FASM. It is not bad, even has a Help system, when you create a new project - it writes the startup code for you, so no blank page there. The site is gone now, but I can probably make a ZIP file with the IDE and post it. Also, I would advise to start with Win32 coding - DOS is way old. And use OllyDbg debugger - I find it even better than Microsoft debuggers from Visual Studio of today even. OllyDbg has a context information at the point where CPU is stopped, tells you all the parameters of Windows API, etc. Awesome debugger! |
|||
03 Nov 2019, 16:04 |
|
rc 03 Nov 2019, 17:45
Thanks AsmGuru62.
Quote: I had a web site once where you can find the IDE for FASM. It is not bad, even has a Help system, when you create a new project - it writes the startup code for you, so no blank page there. The site is gone now, but I can probably make a ZIP file with the IDE and post it. This would be really nice of you. Yes, i allready got a bit familiar with ollydbg. Thanks for the tutorial link, this looks really informative. |
|||
03 Nov 2019, 17:45 |
|
Tomasz Grysztar 03 Nov 2019, 21:22
If you don't mind some video tutorials, I have recently started making them myself. You can find links in the dedicated thread in the "Examples and Tutorials" forum.
Note that I only just started (and I'm in a middle of digression with the 2-adic mini-series, which is technically not a part of the basic tutorial) so only quite elementary things are shown so far. |
|||
03 Nov 2019, 21:22 |
|
DimonSoft 03 Nov 2019, 21:55
rc wrote: Yeah that was what I was thinking too: would it make sense to start learning 16 bit assembly on DOS first? I have set up freeDOS on a vm, although I could probably use dosbox as well. Would you suggest me learning 16 bit first? Starting from MS-DOS programs is a good idea, just not very popular because most people think it is out-of-date, thus “not worth spending time”. In fact, it is absolutely good way to start since you get the simplest x86 environment possible which helps getting the feeling of the platform. You can always reuse the knowledge gained moving to Windows and protected mode. But I’d suggest using a virtual machine with Windows XP for MS-DOS development and debugging these days. Much more comfortable compared to plain DOS or modern Windows + DOSBox. And the experience in using virtual machines is also quite useful anyway. |
|||
03 Nov 2019, 21:55 |
|
rc 03 Nov 2019, 21:59
Hello Tomasz Grysztar,
nice to talk to the creator of fasm. This tutorial series would exactly be what a beginner in (f)asm (like myself) would like to have when beginning. Starting slow with the very basics, and slowly go into more advanced topics like the winapi maybe. Really appreciate your effort. Thanks a lot for these turorials! I like that you dont rush through the commands and take the time to show what exactly they are doing in the debugger! Please don't stop making them, as they are probably the best resource on assembly on the net, especially for beginners with fasm. @DimonSoft: Yes, i only do programming in VMs. I have a windows 10 host running a win10 developer vm. And also win7 testing enviroments. I never develop on host machines. I have set up qemu and freedos and already played around with fasmd. I really like dos i have to admit. To bad it is pretty outdated by now and nobody is using it anymore. But luckily i still have several WinXP copies lying around somewhere. Last edited by rc on 03 Nov 2019, 22:22; edited 5 times in total |
|||
03 Nov 2019, 21:59 |
|
AsmGuru62 03 Nov 2019, 22:01
Hi rc,
So, I attached the IDE to this post. No installer there, just unzip it. First thing is to go to Help folder and open HTML file and read it. This document is slightly outdated - I added few features to IDE after it was written, but never bothered to update HTML.
|
|||||||||||
03 Nov 2019, 22:01 |
|
rc 04 Nov 2019, 12:51
Hi AsmGuru62,
thank you a lot for the upload. The ide is really nice! Such a project in assembly.. quite impressive! |
|||
04 Nov 2019, 12:51 |
|
bitshifter 04 Nov 2019, 13:06
The best way to learn is by example and documentation, download the fasm manuals/examples and cpu manuals, then play with the examples, make changes, break them then fix it, then you will understand how it works.
|
|||
04 Nov 2019, 13:06 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.