OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Sep 18, 2021 5:12 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Regarding For Assembly Language
PostPosted: Thu Sep 24, 2020 2:09 am 
Offline

Joined: Thu Sep 24, 2020 1:51 am
Posts: 1
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.


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Fri Oct 23, 2020 10:24 am 
Offline

Joined: Fri Jan 31, 2020 7:28 pm
Posts: 8
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.

_________________
My public domain NASM OS


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Sat Oct 24, 2020 5:59 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Sat Oct 24, 2020 8:04 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 2716
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.


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Sat Oct 24, 2020 8:20 am 
Offline
Member
Member

Joined: Fri Nov 22, 2019 5:46 am
Posts: 590
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


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Sat Oct 24, 2020 10:18 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Sat Oct 24, 2020 10:43 am 
Offline
Member
Member
User avatar

Joined: Tue Sep 15, 2020 8:07 am
Posts: 263
Location: London, UK
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.

_________________
CuriOS: A single address space GUI based operating system built upon a fairly pure Microkernel/Nanokernel. Download latest bootable x86 Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip
Discord:https://discord.gg/zn2vV2Su


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Sat Oct 24, 2020 11:00 am 
Offline
Member
Member

Joined: Fri Nov 22, 2019 5:46 am
Posts: 590
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


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Sun Oct 25, 2020 8:23 am 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 585
Location: Flying strange spaceplanes in a distant solar system
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.

_________________
Pixel Forth


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Sun Oct 25, 2020 8:50 am 
Offline
Member
Member

Joined: Fri Nov 22, 2019 5:46 am
Posts: 590
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


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Sun Oct 25, 2020 9:39 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Fri Jan 15, 2021 2:52 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 2716
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.


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Fri Jan 15, 2021 11:49 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Fri Jan 15, 2021 1:00 pm 
Offline
Member
Member

Joined: Fri Nov 22, 2019 5:46 am
Posts: 590
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


Top
 Profile  
 
 Post subject: Re: Regarding For Assembly Language
PostPosted: Fri Jan 15, 2021 1:09 pm 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 846
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.

_________________
Working on NexNix, which is an attempt to reimagine Unix as much as possible


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group