87

Does this mean the base pointer or the stack pointer are actually moving down the memory addresses instead of going up? Why is that? Yes, the push instructions decrement the stack pointer and write to the stack, while the pop do the reverse, read from the stack and increment the stack pointer. This is somewhat historical in that for machines with limited ...


56

You young whippersnappers amaze me sometimes. You all too often have no clue that anything happened before you started school. (I have the same problem. It took me a long time to grasp that 15 years was actually a very short time, from an adult viewpoint. That's roughly the span from Hiroshima to the Cuban Missile Crisis. To me, World War II is just ...


43

Knuth discusses his reasoning in the Preface. I'll quote just a few bits and pieces: ...I needed to decide whether to use an algebraic language such as ALGOL or FORTRAN, or to use a machine-oriented language for this purpose. Perhaps many of today's computer experts will disagree with my decision to use a machine-oriented language, but I have become ...


32

If I understand correctly, the development process was peer review and experimentation. The team consisted of people like "Math Doctors" - extremely dedicated, intelligent, passionate, detail-oriented folks whose lives were dedicated to their work. So when I say peer review, I mean many peer reviews over the course of many months (more than a year). These ...


30

Look at the instruction set documentation, and you will find entries like this one from a pic microcontroller for each instruction: The "encoding" line tells what that instruction looks like in binary. In this case, it always starts with 5 ones, then a don't care bit (which can be either one or zero), then the "k"s stand for the literal you are adding. ...


29

Knuth has updated his rationale as well: Why have a machine language? Many readers are no doubt thinking, ``Why does Knuth replace MIX by another machine instead of just sticking to a high-level programming language? Hardly anybody uses assemblers these days.'' Such people are entitled to their opinions, and they need not bother reading the machine-language ...


22

He not only uses MIXAL, his assembly language for MIX, but also MIX, a model for a simple computer (like one which was used in the sixties). This is a model for teaching with which he is, to some extent, independent of development in the field. If he'd used another programming language (which one, by the way, would you think would have been suited?), say ...


21

The red zone is, purely and simply, an optimization that can save instructions. It means that it's no longer necessary for the emitted code for every function to subtract from the stack pointer to make local storage like so sub XXX, %rsp at the beginning of every function call, even if they are not leaf functions. Often times the code emitted from the ...


18

I'd start by checking Lua. Both as a sample implementation, and as a very usable VM/language out of the box if you finally decide not to roll your own. The source code is very readble, and there's also the Annotated source code. And some Design documents written by the main author, Roberto Ierusalimschy. Finally, if you choose to use it instead of your ...


18

People have written assemblers in machine code. They've also written then in assembly language--often a subset of the language they translate themselves, so they start with a simple "bootstrap" version of the assembler, then add features to it as they need them for the assembler itself. However, none of this is particularly a necessity. In the end, an ...


18

They seem to mean simple textual concatenation / insertion. In other words, even though the source text was split into individual files, the program wasn't split into modules.


15

The performance overhead of writing lots of data to disk isn't the execution speed of your code, but rather the physical limitations of the actual hard drive. Doing it assembly won't give you a noticeable performance increase. Your best bet is to either log less data (recommended, if you're logging that much stuff how useful can it be) or change the drives ...


15

The AGC is controlled with verbs and nouns The Apollo command software is not written in any syntax users would recognize today. Astronauts input commands numerically, with each two-digit number representing a verb or a noun. The verb described the action to be performed, and the noun specified the data to be affected by the verb’s action. Astronauts hated ...


14

There was a lovely documentary I'm trying to chase down about John 'Jack' Garman had to "invent" a "a priority-scheduled multiprogramming operating system". This may have been related to the lander module though. The story was that when you were landing the lander, you better give priority to guidance because other things, like the temperature in the cabin ...


13

Essentially, through configuration options. A compiler that understands multiple back-ends will usually assume that source code should be compiled to the platform (os + processor type) on which the compiler itself is running. Everything else would be cross-compiling, and would have to be specified via command-line switches or configuration files.


11

Contrary to what anyone would say, knowing how memory works is important to know for any language, regardless of whether or not a specific language requires you to know it. For low level languages like C, memory addresses are very important to know because dedicating space to arrays or complex data structures requires a physical act of asking the operating ...


11

In some instruction sets, there exist distinct instructions to load a register from memory, store a register to memory, or transfer things among registers. While some assembly language forms use the verb "load" for everything (e.g. Zilog's Z80 mnemonics use ld a,(1234h), ld (1234h),a and ld a,b) , and some use "T"ransfer (e.g. the 6502 with TXA for "...


11

You are seeing connections that don't exist. "Write an assembler" is a programming task just like any other programming task. You use the tools to handle that task that are best for that task. There is nothing special about writing an assembler; there is no reason at all not to write it in a high level language. C is actually at a quite low level, and I ...


11

You cannot make a portable compiler (not in the sense you dream of). You could make a compiler for a particular target machine -or language- (and that machine might even be something like LLVM or GCCJIT or Parrot which provide portability by defining some abstract model or intermediate language). It is common to compile to C (that is to choose C as your ...


10

Assembly opcodes have, for the most part, a one-to-one correspondence with the underlying machine instructions. So all you have to do is identify each opcode in the assembly language, map it to the corresponding machine instruction, and write the machine instruction out to a file, along with its corresponding parameters (if any). You then repeat the ...


10

Assembly was never a mainstream language. You learn it for the same reasons that people learned it in the 80s/90s, and before that: it's close to the metal. Learning assembly language: Teaches you how the machine works, and Gives you access to the best possible performance (in theory). I say "in theory," because it doesn't come without a cost. ...


10

In common assembly, it's accomplished by various conditional jumps, e.g. cmp %eax, 1; je label Which roughly translate to "compare register eax and constant 1; if equal, jump to label. Otherwise, the next instruction is executed. The result of cmp is stored in the status register. It's a register containing results from arithmetic operations such as the ...


10

Because the width of the data bus and the size of the smallest addressable unit are two separate things. Just because you can specify addresses at the byte level, does not mean you have to have an 8 bit data bus. Most (possibly all) modern x86 processors use a 64 bit data bus and every time they read from memory, they read 64 bits. If you only requested 8 ...


9

Historically there were various ways:- No OS at all. Executable was loaded in from first card, tape file or whatever. Os hard coded in magnetic core memory. Cores were permanent magnets instead of plain ferrite, depending on the N/S orientation of the magnet it was a one or zero. The computers in the Gemini and Apollo spacecraft had all their programs "...


9

What were they doing in the past while the absence of C language? Were they writing Assembler in Machine Code? Assembly is essentially a mnemonic for machine code; each opcode in the machine language is given an assembly mnemonic i.e. in x86 NOP is 0x90. This makes assembler's rather simple (n.b. most assemblers have two passes, one to translate, and a ...


9

There's a huge body of research on this topic, so I really recommend reading a compiler book. Muchnik's book can work well as a reference. I really like Modern Compiler Implementation but I think it's out of print. If you're the kind that learns better by reading code, the Scala compiler does all of the above, and the JVM fits all of the bullet points you ...


8

I find this definition pretty clear: The Instruction Set Architecture (ISA) is the part of the processor that is visible to the programmer or compiler writer. The ISA serves as the boundary between software and hardware. The ISA provides an abstraction of the actual microarchitecture, which is the implementation of the instruction set by the processor. ...


Only top voted, non community-wiki answers of a minimum length are eligible