OSDev.org
https://forum.osdev.org/

Regarding For Assembly Language
https://forum.osdev.org/viewtopic.php?f=13&t=37267
Page 1 of 2

Author:  ankitdixit [ Thu Sep 24, 2020 2:09 am ]
Post subject:  Regarding For Assembly Language

Hello All, Can anyone help to find best assembly language tutorial in free or paid version? I am an intern and working on some online projects where i need to explore more about assembly language. Please suggest me.

Author:  FranchuFranchu [ Fri Oct 23, 2020 10:24 am ]
Post subject:  Re: Regarding For Assembly Language

Tutorialspoint has a good tutorial for x86 Linux assembly programming. It teaches basic NASM syntax and concepts. https://www.tutorialspoint.com/assembly_programming/
MikeOS (a real-mode x86 OS) has a tutorial for developing applications for it (maybe it's easier for you): http://mikeos.sourceforge.net/handbook-appdev-asm.html
MikeOS also has an introduction to make an real mode OS from scratch (again, in x86): http://mikeos.sourceforge.net/write-your-own-os.html

You might need a VM to follow the tutorialspoint tutorial, and it's a good idea to use VM for the MikeOS ones.

Author:  bzt [ Sat Oct 24, 2020 5:59 am ]
Post subject:  Re: Regarding For Assembly Language

Hi,

I'd strongly suggest to take a look at flatassembler. It is one of the best assemblers out there, and its documentation has many useful examples and tutorials.
It also has a very friendly and helpful community, and they post tutorials regularly on their forum. You can find examples for literally everything, starting from a boot sector to a complete SDL game engine.

Cheers,
bzt

Author:  rdos [ Sat Oct 24, 2020 8:04 am ]
Post subject:  Re: Regarding For Assembly Language

The problem with these different syntaxes is that once you start to use them you cannot switch. So people get locked into assemblers, and when and if they are no longer developped, the code will become useless or hard to build.

I use the TASM ideal mode (actually WASM, but it is TASM compatible). I think memory references should use [] and that offset should be used to indicate that you will use the address rather than the data. In NASM, just using a variable will translate to using the address. I have kind of prepared for this problem by always using segment overrides on memory operations even when not necessary as this should trigger errors when expecting an address. This also overrides the assume directive in ideal mode which can give unpredicatable results.

So, I think all these assembler variants are quite unfortunate.

Author:  PeterX [ Sat Oct 24, 2020 8:20 am ]
Post subject:  Re: Regarding For Assembly Language

rdos wrote:
In NASM, just using a variable will translate to using the address.

I'm not sure if I understand you right.
I think
Code:
mov rsi, label1

will put the offset of label1 into the register while
Code:
mov rsi, [label1]

will put the data at that offset into the register.

EDIT: Maybe you mean MASM/TASM?

Greetings
Peter

Author:  bzt [ Sat Oct 24, 2020 10:18 am ]
Post subject:  Re: Regarding For Assembly Language

rdos wrote:
The problem with these different syntaxes is that once you start to use them you cannot switch.
I can only speak for myself, but for me this was never an issue.

I've started Assembly for x86 with MASM, then I switched to TASM. I've used that for a long time. Then when I migrated to Linux, I've played a bit with NASM, but that wasn't for my liking really. These days I'm using FASM (Intel-like) and GAS (AT&T) regularly in parallel, and I have no issues whatsoever with the different syntax (except that FASM's syntax is far more superior, I miss a lot in GAS, but I can always manage).

PeterX wrote:
EDIT: Maybe you mean MASM/TASM?
Sounds more like GAS I think.

Cheers,
bzt

Author:  bloodline [ Sat Oct 24, 2020 10:43 am ]
Post subject:  Re: Regarding For Assembly Language

rdos wrote:
The problem with these different syntaxes is that once you start to use them you cannot switch.


I kind of agree with this. The only assembler I’ve ever really done is on the 68000, and the convention there is opcode.size source, destination (linguistically it’s the imperative in English: Verb subject object - Add D0 to D1 ) so over the past month where I’ve been doing a lot of x86 I’ve found AT&T syntax much easier than Intel syntax. I only use GAS which supports both styles, but I find it so much slower to parse Intel syntax.
A good asm coder would have no problem reading either.

Author:  PeterX [ Sat Oct 24, 2020 11:00 am ]
Post subject:  Re: Regarding For Assembly Language

bzt wrote:
I'd strongly suggest to take a look at flatassembler. It is one of the best assemblers out there, and its documentation has many useful examples and tutorials.
It also has a very friendly and helpful community, and they post tutorials regularly on their forum. You can find examples for literally everything, starting from a boot sector to a complete SDL game engine.t

I had a look at it and it is impressing. For example they have a gtk GUI example. And many other examples.

rdos is probably right, because I still won't shift from Nasm to Fasm.
But it is possible to understand different Assemblers and different syntaxes. I can read AT&T syntax despite being a Nasm user/fan. I can recommend the method I mentioned elsewhere: Try very hard to understand the different syntax (and fail) and then put it aside for two weeks or whatever. Then try to understand it again. You will probably notice that your brain is more ready for the topic than it was before. Maybe you need more than two tries, but in the end it works (for you, too, I hope). So I learned to read Lisp. And I must say first Lisp was a kind of parenthesis hell for me...!

Greetings
Peter

Author:  eekee [ Sun Oct 25, 2020 8:23 am ]
Post subject:  Re: Regarding For Assembly Language

bzt wrote:
I'd strongly suggest to take a look at flatassembler. It is one of the best assemblers out there, and its documentation has many useful examples and tutorials.
It also has a very friendly and helpful community, and they post tutorials regularly on their forum. You can find examples for literally everything, starting from a boot sector to a complete SDL game engine.

I may very well do that myself. I like things about Nasm and it's very widely praised, but Nasm's forum is practially dead, probably because it requires completion of a painful captcha for every post. Besides, I've heard Fasm (the common name of flatassembler) has some technical advantages.

rdos wrote:
The problem with these different syntaxes is that once you start to use them you cannot switch.

Switching anything you use daily is an interesting topic with neurological and psychological aspects. I had trouble with keyboards. Occasionally I still do. To some extent it's possible to improve your switching skills, but mostly I think that's just a case of learning not to confuse the separate... muscle memories. We need a term for things which are exactly like muscle memory but not related to actual muscles.

Author:  PeterX [ Sun Oct 25, 2020 8:50 am ]
Post subject:  Re: Regarding For Assembly Language

eekee wrote:
rdos wrote:
The problem with these different syntaxes is that once you start to use them you cannot switch.

Switching anything you use daily is an interesting topic with neurological and psychological aspects. I had trouble with keyboards. Occasionally I still do. To some extent it's possible to improve your switching skills, but mostly I think that's just a case of learning not to confuse the separate... muscle memories. We need a term for things which are exactly like muscle memory but not related to actual muscles.

I could name it reflexes or instincts. But you probably mean the unconscious, the automatisms.

All I can say is: The human mind can learn many things. And it seems to me that there are four rewards when you are programming:
(a) Learning new things and (b) achieving results. And maybe (c) the process of coding and (d) the process of planning and designing.

I suggest to every Asm coder trying to learn both Asm syntaxes.

Also note that someone implemented into Gas 99% compatibility with Nasm (including Intel syntax).

Greetings
Peter

Author:  bzt [ Sun Oct 25, 2020 9:39 am ]
Post subject:  Re: Regarding For Assembly Language

eekee wrote:
Besides, I've heard Fasm (the common name of flatassembler) has some technical advantages.
Indeed it has!
  • It is written in fasm, compiles itself
  • Being written in Assembly, extremely fast (I mean seriously, VERY VERY fast)
  • Supports virtually all formats (ELF, PE, COFF, AOUT etc. etc. etc.)
  • Easy to port (available for Win, Linux, MacOS, BSDs, and there's a special bootstrap version which only needs to be linked with your OS' libc)
  • Comes with a powerful IDE (sadly Win only)
  • Full instruction support, up to the latest CPU features
  • It's macro system is one of the best I've ever seen, and I've seen a lot. I calculate BIOS ROM checksum with its macros on-the-fly for example :-)

Actually there's a next generation of fasm (fasmg), where even the instructions are implemented as macros, therefore you can switch CPUs with a simple include. (fasm was originally written for x86, but there's a fasm-arm version too. With fasmg you can assemble for both x86 and ARM, and even for M68k etc. This flexibility comes at a price though, fasmg is slower than fasm, but still pretty fast).

Cheers,
bzt

Author:  rdos [ Fri Jan 15, 2021 2:52 am ]
Post subject:  Re: Regarding For Assembly Language

eekee wrote:
rdos wrote:
The problem with these different syntaxes is that once you start to use them you cannot switch.

Switching anything you use daily is an interesting topic with neurological and psychological aspects. I had trouble with keyboards. Occasionally I still do. To some extent it's possible to improve your switching skills, but mostly I think that's just a case of learning not to confuse the separate... muscle memories. We need a term for things which are exactly like muscle memory but not related to actual muscles.


It's not so much the psychological aspect of learning something new rather that the code you already wrote doesn't compile or even worse, compile but then doesn't work since the new assembler has different rules.

An example is this:

mov eax,some_var

In TASM syntax this means load eax with the value of some_var while in nasm it means load eax with the address of some_var. Both of these assemble correctly in both TASM and NASM, but produce different code. So, if you have a large codebase in TASM syntax you cannot switch to NASM if you use this syntax since you would need to go through every line of code and check memory references.

FASM seems completely useless since it only produces flat binaries. Even if it didn't, letting the assembler rather than the linker produce the executable is generally a bad idea.

Author:  bzt [ Fri Jan 15, 2021 11:49 am ]
Post subject:  Re: Regarding For Assembly Language

rdos wrote:
So, if you have a large codebase in TASM syntax you cannot switch to NASM if you use this syntax since you would need to go through every line of code and check memory references.
So by "switching" you don't meant a programmer multiplexing between projects with different syntax, but actually converting codebases? I can assure you, that sucks with all languages and syntaxes, no matter what.

rdos wrote:
FASM seems completely useless since it only produces flat binaries.
Now where did you get that? FASM can generate lot more kind of object files than NASM. Look up "format" directive in the documentation.

rdos wrote:
Even if it didn't, letting the assembler rather than the linker produce the executable is generally a bad idea.
First, why? Second you can produce linkable objects just as well as executables, DLLs and shared objects. Just a matter which options you use for the "format" directive.
Here is an example which produces an .obj file then links it with an MSVC compiled .obj to produce the final executable.

Cheers,
bzt

Author:  PeterX [ Fri Jan 15, 2021 1:00 pm ]
Post subject:  Re: Regarding For Assembly Language

bzt wrote:
Now where did you get that? FASM can generate lot more kind of object files than NASM. Look up "format" directive in the documentation.

http://flatassembler.net/docs.php?artic ... _manual#14 says:
Quote:
Currently the only available choice is "format binary"

I hope this is outdated and false.

Greetings
Peter

Author:  nexos [ Fri Jan 15, 2021 1:09 pm ]
Post subject:  Re: Regarding For Assembly Language

PeterX wrote:
bzt wrote:
Now where did you get that? FASM can generate lot more kind of object files than NASM. Look up "format" directive in the documentation.

http://flatassembler.net/docs.php?artic ... _manual#14 says:
Quote:
Currently the only available choice is "format binary"

I hope this is outdated and false.

Greetings
Peter

I think that manual you pointed to is for fasmg.

Page 1 of 2 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/