Yep, that's how I got into assembly too. The C64 was nice, BASIC was fairly simple to learn. I wanted to write games and quickly found out BASIC wasn't fast enough. Read lots of magazines that had programs you could type in. A lot of them consisted of pages upon pages of just numbers. This turned out to be machine code. Never managed to write my own games but I did learn 6502 assembler. This involved many, many visits to the local library. At school I got to the 6809 (which is quite similar to the 6502). And in the meantime I bought an Amiga and thus moved to 68000 assembler to write demos. The switch from 8 bit to 32 bit was very easy. Once you get to understand how registers, program counters and logic works it doesn't really matter if it's 8, 16 or 32 bit. The opcodes may change (MOVE instead of LDA for example) and the registers are bigger (and you typically have more of them) but the basic principles are exactly the same.They tend to be 30-40 years old; in those days, assembly programming was necessary, because the only alternative on computers hobbyists could afford (like Commodore 2001 or Apple II) was BASIC, which ran too slow, and used too much memory. Many of the books were not actually assembly programming books, but the reference manuals for the CPUs, which explained the architecture (registers, memory model, data flow) and the instruction set.
as
. There is also the Intel syntax which is used by numerous assemblers like NASM.Thank you,Don't know if it will of some use but in the FreeBSD code, you have some assembly codes in stand/i386/mbr, stand/i386/pmbr and stand/i386/btx among other places. These codes work in real mode which is the base of x86 processors. The last one (btx) is very interresting as it switches the processor in protected mode.
Reading theses codes, you have not only the startup of FreeBSD in BIOS legacy mode but also the essence of the x86 processors. It just lacks the 64 bits mode.
But it's maybe a little hard for a true beginner, I wonder. However, before to play music, it's a good idea to listen music, isn't it?
You have to note that these codes are written with the AT&T syntax used byas
. There is also the Intel syntax which is used by numerous assemblers like NASM.
Last thing, if you want to understand these programs, you have to dig into what they do. I mean MBR and GPT schemes in these examples.
push rdi
BITS 64
DEFAULT rel
global _start:function
SECTION .text
_start:
mov eax, 1 ; Syscall (exit)
xor edi, edi ; Return Value
syscall
Last I read about this--and it's strange I remember--there are 4400 lines of assembly in the FreeBSD kernel.Very little code (if there's any at all) of FreeBSD is assembler.
Not on FreeBSD but I'm looking forward to writing assembly for a Linux driver in a few weeks.There are just about no good reasons to write assembly.
Assembly is fun! When you feel the need for speed. When you need direct control. I know I don't have to explain these things to you.Why?
I want book to explain how to programming FreeBSD with assembly line use system call and manipulating kernel and others things.
Looks like the answer here is "out of interest, for learning".why actually assembler, *today* ?
I support edu, for sure!Well, I like the picture of the books But they are for a different architecture (m68k).
Looks like the answer here is "out of interest, for learning".
If that's indeed the case, I'd think about whether I really want to dive into x86. x86 is a very complex (CISC on speed) architecture, designed with compilers in mind, not so much humans writing the code. Of course, it still might be interesting, but be prepared to have to learn a lot before you can actually write some code doing anything useful.
The m68k architecture (used e.g. in older Amigas or Macs) is a lot simpler and actually meant to be "hand programmed". You could go to something even simpler, like the 6502 (which IMHO is really fun to program in assembler), e.g. used in the famous C64, the Apple II, and so on
I really enjoyed Assembly Language Step By Step by Jeff Duntemann. It's an introduction for the 32-bit x86 instruction set so don't expect it to be the last book you read on assembly language. Other books I looked at first out all felt like reference manuals for the x86 instruction set, whereas this book actually teaches programming. The author says it can be used by people without programming experience, though I came to it with experience in a variety of higher level languages including C.Is there any books for help me to improve with that.
The original book. Not the "High Level Language" newer one. Randy went off the tracks with that one and we had many fierce arguments about that nonsense.The Art of Assembly Language
I gave a link for the FreeBSD chapter earlier in this thread.Now, for writing assembly language specifically for FreeBSD
Just like C, one can begin with a number of basic instructions and do quite a bit with that. But you also have to have an understanding of the internals of the microprocessor and its interaction with outside components and timing. Assemblers didn't help much with layout in memory but I'm betting they're better now.be prepared to have to learn a lot before you can actually write some code doing anything useful.
Definitely you have to read a book from first to last page. The problem is that instructions are different for each CPU. It is good to learn something practical like 8-bit Atmega. Then you can look 8086, 80386 and x64 instruction set to have notion for complex instruction set (compared to Atmega). Finally, return to C - it is like abstract assembly.