115

One use is as a copyright mechanism. Many distributors would steal/copy programs and sell pirate or derivative copies, by changing the text strings inside the code and reordering the blocks, it was hard to prove the code had been stolen. Placing noops of different types you could put a signature sequence which was much easier to detect and hard to hide. A ...


96

The short answer is that DOS was designed to be similar to CP/M, and drawing a quote from here: While 8-bit programs could not run on 16-bit computers, Intel documented how the original software developer could mechanically translate an 8-bit program into a 16-bit program. Only the developer of the program with possession of the source code could ...


76

This is an example of BBC BASIC with inline (6502) assembler code. The computer in use would have been a BBC Microcomputer, manufactured by Acorn Computers Ltd. The display was probably a studio monitor of some sort. These could be driven directly using either the RGB output or the composite video output of the microcomputer. It is likely that the actual ...


72

C did exist when DOS was developed, but it wasn’t used much outside the Unix world, and as mentioned by JdeBP, wouldn’t necessarily have been considered a good language for systems programming on micros anyway — more likely candidates in the late seventies would include Forth and Pascal. SCP developed DOS in assembly for a few very pragmatic reasons: The ...


71

According to Wikipedia, the first assembly language was developed in 1947 by Kathleen Booth (née Britten). The language doesn’t look anything like “modern” assembly though (see the end of this paper); it’s more a mathematical representation of computer operations. The first mnemonic-based assembler was developed by Maurice Wilkes and David Wheeler for the ...


70

The NES was also from the era where some sound and graphics resources were also executable code. (Typically, this worked the other way around. Identify a needed sound and listen to chunks of the binary to find a reasonable candidate.) Injecting NOPs can improve the look or sound derived from a section of executable. Example: "One of the more-challenging ...


68

TL;DR; Using INT comes not only natural due the way the 8086 is designed, but was as well intended by Intel as OS entry point, much like a Supervisor Call (SVC) on /360 type mainframes: (Excerpt from the October 1979 Intel 8086 Family User's Manual page 2-28.) Software-initiated interrupt procedures may be used as service routines ("supervisor calls&...


53

The 8 bit 6502 family doesn't have any stack-relative addressing modes that would make it easy to use the stack for variable storage. One can access values on the stack with a sequence such as TSX; LDA &102, X, but that's slower, clobbers X, and uses more memory (both in code size and stack usage) than a global variable. The 65C816 adds stack-relative ...


48

Off the top of my head I can think of two reasons, there are probably more. The first reason is that these variables may be set by a routine each frame, and then a lot of code uses them during the time of the whole frame. Every interrupt routine that fires during that frame may want to read out the current direction. The second reason is that, in a real-...


47

Gates and Allen used remote terminal access to a minicomputer (Harvard's DEC PDP-10) to cross-assemble, and simulate, their implementation of BASIC for the Altair 8800. Commodore Basic (for the 6502) is reportedly derived from Altair Basic, and also cross-assembled using Macro-10 on a DEC 10. Woz (and many other early Apple programmers) could code 6502 ...


46

There are no technical reasons, as any order would work and result in the same amount of gates. More likely it originated in the process by which the 8086 was developed. A main goal was to allow easy conversion of 8080 programs, so the development of the 8086 structure started out from a 8080 programming model. 8080 registers were ordered as 16 bit pairs in ...


45

No, DOS won't use any additional CPU (*1) ever. (Though it might run faster due them new CPUs being faster) Quite the same way as DOS doesn't take advantage of the extended memory or additional instructions. DOS is a Single CPU Single User Single Task Single Program Real Mode 8086 operating system. Even through it got a few extensions over time to tap a ...


44

As someone who did it.... We wrote an assembler for an 8080, as there was nothing affordable from Intel. We wrote it in ALGOL 60, if I recall, and ran it on a mainframe. the first thing we ran through it was .. itself, re-coded in assembler. Oh, and a boot-loader, though I think maybe we had already hand-assembled a minimal version of that into binary. ...


44

Yes, BASIC is much slower than assembly for many operations. For an easy example, try out this program on a Commodore 64 or emulator: for i = 1024 to 1984 : poke i,peek(i) or 128 : next You will see each character on the screen reverse, row by row, over the course of ten seconds. By contrast, the exact same routine in machine language inverts the entire ...


42

The premise: Machine language (and Assembly language) don't have the concept of data types is not quite correct, because tagged architecture means exactly this, machine language where the data is tagged for its "type" (even though not quite what we know from higher level languages). Probably the first widespread tagged architecture computer was the ...


37

Besides the matter of semantics and personal taste, there’s a much more practical reason: some instructions sets claim to be copyrighted, as the Wikipedia Z80 article states: Because Intel claimed a copyright on their assembly mnemonics, a new assembly syntax had to be developed for the Z80. This time a more systematic approach was used. So, I think the ...


37

why did high-level language compilers start targeting assembly language rather than machine code Well, the answer is probably: to avoid developing a high level language to binary converter for each language. Issuing assembler text is much easier than issuing binary directly for at least 3 reasons: writing text is easier than writing binary. The compiler ...


36

I'm just speculating here, but one possible reason for using a 2-byte NOP would be if you wanted to change an existing 2-byte instruction into a NOP (to fix a bug, for instance), without changing the byte count for the instruction. (An undocumented 2-byte NOP might execute more quickly than two standard 1-byte NOPs in succession.) You might do this to ...


36

The architecture of the original IBM PC (and its clones) let the BIOS access the video memory directly. So making nice text layouts did not require positioning the cursor or making a sequence of calls like you would do with curses: It was sufficient to set the text mode at startup and write at the right place in memory the character (1 byte) and its ...


34

Machine language (and Assembly language) don't have the concept of data types, so if you want to add an int and a float variable in Assembly, you have to use the appropriate Assembly instruction that adds an int and a float. Erm... this sounds as if you're mixing up the idea of data types and operations on these. Data types are memory structures. Operations ...


33

A mistake? The instruction $89 on the 6502 is a two-byte NOP. Based on adjacent instructions in the opcode matrix, especially LDA #ii ($A9 ii), it would have been STA #ii, a store to an immediate value, which makes no sense. On the 65C02, this instruction is changed to BIT #ii, which almost behaves as a two-byte NOP. One hypothesis is that a programmer ...


33

MADS uses * in three ways (See MADS "Manual") Using the current assembly address for calculation of an address, i.e. the one the actual statement is assembled to. Multiplying in expressions. Mark the beginning of a comment (until line end) In above listing it will be interpreted as the address the JMP instruction is assembled to, so it will form an ...


33

Yes: The Apollo Guidance Computer Uodate: Computers in Spaceflight: The NASA Experience confirms that unit testing was performed on the Apollo software: The simulations followed individual unit tests and integrated tests of portions of the software. At first, MIT left these tests to the programmers to be done on an informal basis. It was very difficult ...


30

From The OS/2 Museum page about DOS3: "The new ATTRIB.EXE utility allowed the user to manipulate file attributes (Read-only, Hidden, System, etc.). It is notable for being the first DOS utility written in C (up to that point, all components in DOS were written in assembly language) and contains the string “Zbikowski C startup Copyright 1983 (C) Microsoft ...


30

TUI-drawing code can be pretty compact when you're working in assembly and relying on the IBM video BIOS to do the heavy lifting. For example: INT 10h/AH=06h and INT 10h/AH=07h can be used either to scroll a rectangular region of the screen or to clear the screen to a specified foreground/background colour combination. INT 10h/AH=09h can be used to tile a ...


30

The MOVE immediate instruction takes 8 cycles in byte and word modes. There are two memory reads, one for the instruction and one for the immediate value. The MOVEQ instruction encodes the immediate value into the instruction op-code itself, so only takes 4 cycles and 1 memory read. It can only take a byte immediate value. MOVEQ #1, D0 (4 clocks, 1 ...


29

Your code runs through the data ("Hello World" string) interpreting it as (nonsense) machine code - and very probably crashes before it even reaches the jmp instruction. You need to move the jmp instruction to before the string.


29

MS-DOS (by which I mean the underlying IO.SYS and MSDOS.SYS files) was written in assembly through the first half of the 1990s. In 1995 for Windows 95, which was bootstrapped by what you would call MS-DOS 7.0 (although nobody ran DOS 7.0 as a stand-alone OS), I did write a small piece of code in C and included it in the project. As far as I know, it was the ...


29

Because "move" is the typical necessary function It isn't always this way, of course, but especially with earlier CPUs, there were limited destinations for data from a particular operation - e.g., arithmetic results could only be in certain registers. Or in the other direction, certain functions could only operate on a few locations, typically registers or ...


28

TL;DR: It is all about making one of the most important instructions as performant as possible, while keeping everything manageable for tools at the time (plus a little bit of dogma). The branching is thus the most optimized instruction of the whole 6502 design. In addition, long branches are not really in demand (*1). Of the 116 branches used in the ...


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