OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Jun 21, 2018 12:17 pm

All times are UTC - 6 hours




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 84 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Thu May 03, 2018 11:32 am 
Offline
Member
Member

Joined: Wed Mar 21, 2018 12:11 pm
Posts: 69
Schol-R-LEA wrote:

I have to second the question which Zaval, and several others, have already asked: what are you trying to accomplish by asking these questions? We've already told you that this is a dead end with regards to professional programming. If you want to learn machine code or assembly language programming out of curiosity or as a hobby, go ahead and do it (Hell, there are probably some here who would help you with that, and there several more specialized message boards where they certainly would), but there is no reason for you to be belaboring this if you intent is to find work.



@Schol-R-LEA

I want to learn machine code and assembly language programming as a hobby.

Who here who would help me with that?

Which are several more specialized message boards where they certainly would?


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Thu May 03, 2018 1:32 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1195
Location: Athens, GA, USA
manhobby wrote:
I want to learn machine code and assembly language programming as a hobby.


OK, then. Fair enough.

Now that we have that settled, which system do you mean to learn assembly (or machine code) for? Each processor family (x86, x86-64, ARM, MIPS, PowerPC, Itanium, AVR, 8051, 6502, etc.) has its own machine code and corresponding assembly language instructions, and different models within a family might not support everything that others in their family do (e.g., the current Xeon Phi, and Skylake-X CPUs have the AVX-512 SIMD math instructions, but most of the other x86 CPUs don't, including the Coffee Lake models released last fall, even though they came out a year after Skylake-X).

Also, writing assembly code that uses any kind of operating system facilities will depend on the OS it is written for, as well; an assembly program for Linux won't run on Windows, and vice versa, even when they are both running on the same hardware.

Conversely, if you intend to write for bare metal, either in the form of a self-booting PC program or something running bare on an SBC such as a Raspberry Pi, Libre Renegade, Imagination Creator Ci40, Onion Omega2, or any of the myriad Arduino systems (or retro-computing boards such as the COSMAC Membership Card or the PE6502), then you would have to write everything yourself, and know enough about the hardware and firmware to do that before you begin. For any sort of bare-metal programming, I would recommend using an emulator or virtualizer when developing the program, and waiting until it works in the emulator before trying to run it on live hardware.

For some operating systems - including Windows and most Unix-like systems such as Linux or MacOS - writing machine code directly isn't really feasible at all, as the systems' program loaders will expect the program to be in a loadable Executable Format such as ELF, PE, or Mach-O - and as complex as writing a program in raw machine code is, writing a loadable executable file in hex would be far worse. Machine code programming is really only something you would want to do on bare metal, if at all.

Finally, for assembly language, it will depend on which assembler you are using - most of the common platforms have at least two or three different assemblers targeting them, and the syntax they accept can be very different from each other.

My recommendation is to settle on a specific hardware and software target, and development toolchain, before proceeding. You will probably want to find a book that covers those specifically, rather than trying to translate one book's information to a different system - and trust me, this is one topic you will want at least one good book on. For example, IMAO one of the best books for programming x86 assembly for Linux using the Netwide Assembler (NASM) is Jeff Duntemann's Assembly Language Step By Step, but it won't do you much good if you are targeting an ODROID (which uses an ARM processor), or an x86 system that is running Windows, or even x86 Linux if you are using GAS.

There are plenty of online assembly language tutorials as well (such as these ans these), and even some for machine code programming, but the quality of them is going to be more variable than that of the books - while terrible books can sometime slide by the editors, most online tutorials don't have editors to fix the author's mistakes.

manhobby wrote:
Who here who would help me with that?


Hmmmn... not sure, really. While most of the assembly programmers here are going to be focused on their OS dev projects, if you post specific questions (not general, open-ended ones like you've been doing) or ask help in debugging something you wrote, I and several others will probably give what advice we can. I couldn't promise any specific individuals other than myself.

Machine code programming, meh, not many here or anywhere else will be able to help with that, really. If you ask a specific question about a specific problem, some of us might try to help, but it would be hit or miss.

manhobby wrote:
Which are several more specialized message boards where they certainly would?


I don't know of any machine-code programming fora offhand, and I have no idea if there are any at all, but there are several for different assembly languages. Let Me Google That For You... OK, here are a few I found. Now, most of these are specific to a particular system or assembler, but they might be a few places to try, depending on what you what to target.

Hope this helps.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
μή εἶναι βασιλικήν ἀτραπόν ἐπί γεωμετρίαν
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Last edited by Schol-R-LEA on Thu May 03, 2018 2:30 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Thu May 03, 2018 2:15 pm 
Offline
Member
Member

Joined: Wed Mar 21, 2018 12:11 pm
Posts: 69
@Schol-R-LEA

Many thanks!


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Fri May 04, 2018 2:29 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2010 4:53 pm
Posts: 984
Location: Scotland
manhobby wrote:
I want to learn machine code and assembly language programming as a hobby.

If you really want to work in machine code as a hobby, you'll need some kind of program to start with which will let you type your machine code numbers into memory and then run your code. You should maybe start by looking at a single-sector OS like BwtSecOS (see the tenth post in https://forum.osdev.org/viewtopic.php?f=15&t=26339) or Selfer (viewtopic.php?f=2&t=26446) - these are self-hosting development systems that fit in a sector and can boot a PC, modify themselves and save themselves back to disk. You could use either of those programs, or write your own single-sector OS based on the same idea, and then try to extend it to add more functionality.

You'll soon find out that to build anything of any size with it, you'll need to automate the repairs to your code whenever it's edited. When you need more space in a routine (to fix a bug or improve its functionality in any way), you have to move parts of it around to make room for the extra code, and that breaks things like jump and call distances. Any variables that are moved will also lead to the parts of code that point at them pointing at the wrong place. Without an automated system to do these repairs, you will waste most of your time fixing them manually (and frequently failing to do so correctly, resulting in crash after crash after crash). That is the main reason that assembler was invented, and it's also why you should put most of your time into learning assembler instead.

_________________
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Fri May 04, 2018 11:02 pm 
Offline
Member
Member

Joined: Wed Mar 21, 2018 12:11 pm
Posts: 69
@DavidCooper,

I liked much the your answer.

Which is the source of your following answer?

DavidCooper wrote:
Without an automated system to do these repairs, you will waste most of your time fixing them manually (and frequently failing to do so correctly, resulting in crash after crash after crash). That is the main reason that assembler was invented, and it's also why you should put most of your time into learning assembler instead.


@DavidCooper,

Which is the main reason that high level languages was invented?

DavidCooper wrote:
If you really want to work in machine code as a hobby, you'll need some kind of program to start with which will let you type your machine code numbers into memory and then run your code. You should maybe start by looking at a single-sector OS like BwtSecOS (see the tenth post in https://forum.osdev.org/viewtopic.php?f=15&t=26339) or Selfer (viewtopic.php?f=2&t=26446) - these are self-hosting development systems that fit in a sector and can boot a PC, modify themselves and save themselves back to disk.


@DavidCooper,

I also want to work in Assembly as a hobby.

What do I need to start to work in Assembly as a hobby?


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Sat May 05, 2018 2:02 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2010 4:53 pm
Posts: 984
Location: Scotland
manhobby wrote:
Which is the source of your following answer?

DavidCooper wrote:
Without an automated system to do these repairs, you will waste most of your time fixing them manually (and frequently failing to do so correctly, resulting in crash after crash after crash). That is the main reason that assembler was invented, and it's also why you should put most of your time into learning assembler instead.

I was only able to make machine code programming practical for big projects by creating a system of indexes that store the addresses of variables, entry points into routines, and all the places in the code where there's a jump distance. Whenever code is shifted by an edit, the affected entries in the indexes have to be corrected, and then the addresses and jump distances in the code have to be corrected too. All these corrections are made by a routine which fixes all the broken bits of code (in a fraction of a second), and then the code is ready to run. If you have any ideas about building something big with machine code, you'll need to design a similar system. Assembler solves the problem in a similar way, but it does all the work at the end of the process rather than after every little edit, not building its indexes until it converts the whole program to machine code (and then throwing them away afterwards).


Quote:
What do I need to start to work in Assembly as a hobby?

Schol-R-LEA gave you links to possible places to find help, such as the NASM forum. However, I don't know which is the best assembler for you to use. If you're working in a high-level programming language and need to use a bit of assembly for something, you need to use an assembler that integrates well with that high-level language, and that's something I have no experience of, so you need to ask other people for advice on that.


Quote:
Which is the main reason that high level languages was invented?

Any assembly code that you write is not portable, so you'll have to rewrite everything if you want to run it on a different kind of processor. You could spend a decade building an OS and set of apps in assembler only to have your project killed off by events which you have no control over - if the processor that your code runs on is no longer used in new machines, all your work is quickly consigned to the museum. That's why most people use assembly as little as possible; just for a few awkward bits that can't be handled using high-level languages. Working in high-level languages is much safer. If you're going to do a lot of work at low level that could be done at higher level, you need to have a very good reason for doing so.

_________________
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Sat May 05, 2018 3:37 pm 
Offline
Member
Member

Joined: Wed Mar 21, 2018 12:11 pm
Posts: 69
@DavidCooper,

Which is the source of your following answer about the high level languages?

DavidCooper wrote:
Any assembly code that you write is not portable, so you'll have to rewrite everything if you want to run it on a different kind of processor. You could spend a decade building an OS and set of apps in assembler only to have your project killed off by events which you have no control over - if the processor that your code runs on is no longer used in new machines, all your work is quickly consigned to the museum. That's why most people use assembly as little as possible; just for a few awkward bits that can't be handled using high-level languages. Working in high-level languages is much safer. If you're going to do a lot of work at low level that could be done at higher level, you need to have a very good reason for doing so.


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Sun May 06, 2018 11:04 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2010 4:53 pm
Posts: 984
Location: Scotland
manhobby wrote:
Which is the source of your following answer about the high level languages?

Why do you need a source? There are very few cases where you can take a program written in assembler and turn it into machine code for more than one kind of processor. The only one I know of is 8080 (a subset of the Z80 istruction set) which can be reassembled to run on x86 where the machine code numbers produced by this are very different (while a program written using the full set of Z80 instructions can't be assembled to run on x86 due to fundamental instruction incompatibilities).

With high-level languages it's different - you only need someone to write a new version of the compiler for your programming language to target a new kind of processor, and then all your old programmes can be recompiled to run on machines using that new chip.

_________________
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Sun May 06, 2018 3:18 pm 
Offline
Member
Member

Joined: Wed Mar 21, 2018 12:11 pm
Posts: 69
DavidCooper wrote:
manhobby wrote:
Which is the source of your following answer about the high level languages?

Why do you need a source?


@DavidCooper,

Because I like much the subject.

@DavidCooper,

Andrew Tanenbaum said that no one programs in machine language today.

According the book of Andrew Tanenbaum, STRUCTURED COMPUTER ORGANIZATION, no one programs in machine language today:


"The reason that people use assembly language, as opposed to programming in machine language (in hexadecimal), is that it is much easier to program in assembly language. The use of symbolic names and symbolic addresses instead of binary or octal ones makes an enormous difference. Most people can remember that the abbreviations for add, subtract, multiply, and divide are ADD, SUB, MUL, and DIV, but few can remember the corresponding numerical values the machine uses.

The assembly language programmer need only remember the symbolic names because the assembler translates them to the machine instructions. The same remarks apply to addresses. The assembly language programmer can give symbolic names to memory locations and have the assembler worry about supplying the correct numerical values. The machine language programmer must always work with the numerical values of the addresses. As a consequence, no one programs in machine language today, although people did so decades ago, before assemblers had been invented".

Why Andrew Tanenbaum did not said that there are always wingnuts, specialists, and hobbyists who do programming in machine language?


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Sun May 06, 2018 5:29 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2010 4:53 pm
Posts: 984
Location: Scotland
manhobby wrote:
According the book of Andrew Tanenbaum, STRUCTURED COMPUTER ORGANIZATION, no one programs in machine language today:...

Why Andrew Tanenbaum did not said that there are always wingnuts, specialists, and hobbyists who do programming in machine language?

He may have made an incorrect assumption that they don't exist based on his own experience of never encountering any, but he was very close to being right. In any case, saying that "no one" does something doesn't literally mean "no one" in most cases. I could say, for example, that no one believes in unicorns, but there's no guarantee that that's true. What is true is that if some people do exist who believe in unicorns, they are so rare that it's normally not worth considering them.

If Tanenbaum knew about my operating system at the time when he wrote the bit you've quoted, he might have worded it differently, but then he might equally have considered my work to be so misguided that it's not worth accommodating it - it would be quite reasonable to decide that it's better for people not to know about it so that they can focus their minds in a better direction. And if he was to consider editing the book now to take my indexed machine code programming system into account, it would complicate what he's trying to say and lead to unnecessary bloat for a trivial gain in accuracy, so why bother?

Tanenbaum says that "The machine language programmer must always work with the numerical values of the addresses", and while that is arguably wrong, you could consider my system to be a partial assembler: my indexes hold the names of variables and routines, so when I call a routine, I type in the name of the routine rather than the jump distance to it, and when I want to load a value from or to a variable, I type in the name of the variable rather than its address. For almost everything else though, I use machine code numbers directly.

_________________
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Sun May 06, 2018 5:54 pm 
Offline
Member
Member

Joined: Wed Mar 21, 2018 12:11 pm
Posts: 69
DavidCooper wrote:

If Tanenbaum knew about my operating system at the time when he wrote the bit you've quoted, he might have worded it differently, but then he might equally have considered my work to be so misguided that it's not worth accommodating it - it would be quite reasonable to decide that it's better for people not to know about it so that they can focus their minds in a better direction. And if he was to consider editing the book now to take my indexed machine code programming system into account, it would complicate what he's trying to say and lead to unnecessary bloat for a trivial gain in accuracy, so why bother?


@DavidCooper,

When you created your operating system?

DavidCooper wrote:


Tanenbaum says that "The machine language programmer must always work with the numerical values of the addresses", and while that is arguably wrong,


@DavidCooper,

Why that is arguably wrong?

@DavidCooper,

Which is the source of your following answer?

DavidCooper wrote:
He may have made an incorrect assumption that they don't exist based on his own experience of never encountering any, but he was very close to being right. In any case, saying that "no one" does something doesn't literally mean "no one" in most cases. I could say, for example, that no one believes in unicorns, but there's no guarantee that that's true. What is true is that if some people do exist who believe in unicorns, they are so rare that it's normally not worth considering them.

If Tanenbaum knew about my operating system at the time when he wrote the bit you've quoted, he might have worded it differently, but then he might equally have considered my work to be so misguided that it's not worth accommodating it - it would be quite reasonable to decide that it's better for people not to know about it so that they can focus their minds in a better direction. And if he was to consider editing the book now to take my indexed machine code programming system into account, it would complicate what he's trying to say and lead to unnecessary bloat for a trivial gain in accuracy, so why bother?

Tanenbaum says that "The machine language programmer must always work with the numerical values of the addresses", and while that is arguably wrong, you could consider my system to be a partial assembler: my indexes hold the names of variables and routines, so when I call a routine, I type in the name of the routine rather than the jump distance to it, and when I want to load a value from or to a variable, I type in the name of the variable rather than its address. For almost everything else though, I use machine code numbers directly.


Last edited by manhobby on Mon May 07, 2018 12:25 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Mon May 07, 2018 5:05 am 
Offline
Member
Member
User avatar

Joined: Thu Mar 10, 2016 7:35 am
Posts: 149
Location: Lancaster, England, Disunited Kingdom
manhobby wrote:

Which is the source of your following answer?



manhobby, what is your source for this question?


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Mon May 07, 2018 5:58 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2010 4:53 pm
Posts: 984
Location: Scotland
manhobby wrote:
When you created your operating system?

About 25 years after Tanenbaum's book was first published.


Quote:
DavidCooper wrote:
Tanenbaum says that "The machine language programmer must always work with the numerical values of the addresses", and while that is arguably wrong,


Why that is arguably wrong?

Because he could claim that I'm not doing pure machine code programming because I've automated that part of the process.

Quote:
Which is the source of your following answer?

...

My answer came out of looking at the evidence and then reasoning about it to try to account for how things came to be the way they are. If you need citations to earn extra points, I can't provide those.

_________________
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Mon May 07, 2018 8:25 pm 
Offline
Member
Member

Joined: Wed Mar 21, 2018 12:11 pm
Posts: 69
DavidCooper wrote:

Tanenbaum says that "The machine language programmer must always work with the numerical values of the addresses", and while that is arguably wrong, you could consider my system to be a partial assembler: my indexes hold the names of variables and routines, so when I call a routine, I type in the name of the routine rather than the jump distance to it, and when I want to load a value from or to a variable, I type in the name of the variable rather than its address. For almost everything else though, I use machine code numbers directly.


@DavidCooper,

You said that is arguably wrong the following affirmation of Andrew Tanenbaum:

"The machine language programmer must always work with the numerical values of the addresses".

Why Andrew Tanenbaum says that the machine language programmer must always work with the numerical values of the addresses?


Top
 Profile  
 
 Post subject: Re: Probable quantity of machine code programmers and Assemb
PostPosted: Mon May 07, 2018 10:35 pm 
Offline
Member
Member

Joined: Mon Jul 25, 2016 6:54 pm
Posts: 110
Location: Adelaide, Australia
manhobby wrote:
@DavidCooper,

You said that is arguably wrong the following affirmation of Andrew Tanenbaum:

"The machine language programmer must always work with the numerical values of the addresses".

Why Andrew Tanenbaum says that the machine language programmer must always work with the numerical values of the addresses?


If I understand DavidCooper, he is saying that he uses machine code, but has an environment that lets him substitute symbols for addresses.
Therefore what Tanenbaum says is not correct, as DavidCooper is a machine code programmer who does not always work with numerical values for addresses.
When Tanenbaum said it though, he believed that it was correct. At the time the book was printed there was no way to use machine code without using numerical addresses. Traditionally substituting symbols for addresses is a feature of an assembler, so traditionally that feature is not possible when working with raw machine code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 84 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 2 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