Hot answers tagged

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 ...


78

With a powerful enough microscope, you can see each transistor. Reverse-engineering silicon then boils down to carefully removing each layer (ceramic or plastic to expose the chip, then each metal layer), taking detailed photographs, and figuring out what each part does. For CPUs of the era, this was already possible in the early eighties. Ken Shiriff does ...


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 ...


49

(More of a memory dump related to Stephens Answer) At a time when ICs were of low complexity (compared today), could you actually see each transistor on the silicon and reverse engineer it? Yes. Just try it yourself. Take some 1980s TTL, like a 7400 - I'm sure you find some on old boards - and crack it open. Usually it separates well from the plastic. Put ...


45

Sinclair didn't always use the Z80 for its computers. The MK14 computer, sold in kit form (like the ZX80 was), used a National Semiconductor INS8060. The ZX range of home computers have a video display hardware that is very closely tied to the architecture of the Z80. On the two first models, ZX80 and ZX81, the video display hardware was kept to a minimum, ...


45

Setting and clearing carry, the decimal or interrupt flags is useful: the carry flag because the 6502 offers only add and subtract with carry; the decimal flag because it changes the mode of the processor; and the interrupt flag because it masks or unmasks the maskable interrupt. Conversely, explicitly setting and clearing the other flags mostly isn't ...


45

Like all games from that era, cheating and tables. Two 256 byte tables and logarithms gave a 10x speed boost on multiply and divide on Commodore 64 at least. Matrix operations using addition only for fixed known rotation rates. Lazy evaluation. Only convex shapes making hidden line removal simpler and hidden line removal meaning only half the vertices ...


44

The 6502 CPU is just one piece of the puzzle Emulators emulate entire machines, not merely CPUs. Even the likes of QEMU emulate an entire generic computer. It helps if you think of the Apple II and NES not as singular units but as networks of components. The CPU, graphics unit, RAM and so on all have communications to each other and do so at a very fast ...


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 ...


44

One language that was popular on early 8-bit micros, including those that used the 6502 CPU, was Forth. Forth is exceptionally good for this use case, and superior to a C compiler, because Forth can make more efficient use of the 6502's hardware stack. Forth lacks any sophisticated methods of dealing with parameters. Everything is passed through the Forth ...


41

Early MOS documentation (KIM-1 Programming Manual, Synertek SY6500/MCS6500 Microcomputer Programming manual, etc) states: The BIT instruction actually combines two instructions from the PDP-11 and MC6800, that of TST (Test Memory) and (BIT Test). ... In addition to the nondestructive feature of the BIT which allows us to isolate an ...


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 ...


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

The simple answer is that early operating systems for the systems you mention did not provide those features. Apple DOS, for example, makes no use of interrupts, and has no concept of processes or memory protection. Nor does DOS have any concept of hardware drivers, as it includes support to drive the Disk II (a deep assumption in DOS) and nothing else. ...


32

First, for Commodore's part, it should be obvious the reason for choosing the 6502 microprocessor for all their 8-bit machines (notwithstanding the dual-processor CBM 9000 and C128) - Commodore owned MOS. Jack Tramiel was very focused on vertically integrating his manufacturing, which basically assured Commodore's use of MOS CPUs and support chips. Since ...


31

No, they cannot. They share both the data and the address bus of the C128, so they can only run exclusively at any one point in time. The address bus is apparently directly connected, the data bus of the Z80 through a set of latches to the data bus of the rest of the system. In CP/M mode, the 8502 is handling keyboard, screen and printer and serial ...


31

An instruction set can be considered as a Huffman coding of an idealised instruction stream. So the question is really asking which CPUs have a good balance of short encodings for common tasks to longer encodings for rare tasks. However, it is not sufficient to just look at the encoding of individual instructions because a RISC instruction generally does ...


31

There are many answers to this and none might satisfy you. First of all, an Emulator doesn't just do a CPU, but a machine. The same way you can't run an NES game on an Apple II. So while one may do multiple ones, different can do the hob as well. Furthermore, there are different target platforms. Linux isn't Windows which again isn't MacOS and so on. Like ...


30

The 6502 had 16-bit addressing but only an 8-bit adder. For an indexed load or store, the index register had to be added to the base address in two steps. As an optimization, the 6502 will load from memory as soon as the first part of the add is complete. If the add didn't cause a carry out, the loaded value is kept. If it did cause a carry, the value is ...


29

Both processors are cacheless. So the process is fetch instruction, decode instruction, execute instruction, forget what you saw. That provides a first line of comparison. The Z80's fastest memory fetch — the first half of an operation fetch — takes two cycles. That's always paired with another two cycles for refresh though, so the shortest instructions are ...


29

I'm having a hard time picturing a use for this [BIT] It's mainly an I/O issue. The 6502 is in many ways designed especially for control/embedded applications and BIT is a part of this. 6500 specific IO-devices are designed to report any service conditions on bit 7 (and 6). For example the 6522 will set bit 7 of the Interrupt Flag Register when an ...


28

For "home" computer systems such as the Apple II, the "operating system" wasn't anything like a modern one with processes and device drivers and so on; by the standards of modern OSes there wasn't really one at all. As a warning: all these explanations (long as they are) are for the most part considerably simplified. This answer is ...


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 ...


28

It's worth noting what you can see, and what you can't. First, you cannot see any feature that is much smaller than the wavelength of light that you are using. In 1995 I designed a chip for my Master's thesis in 1.2um technology; features are clearly visible under microscope. Features in 0.5um technology might be visible, but by 1997 0.25um technology was ...


26

There is simply no need for setting Overflow. The same is as well true for Negative/Sign and Zero. No operation will be influenced by any of them, it's only used to signal an overflow during ADC and SBC (well, and BIT for testing bit#6). In fact, the question is rather, why there is a CLV present, as there is no reason, within the boundaries of the ...


25

On the BBC Micro, the byte after the BRK instruction held the error number, followed by the error message string terminated with 0x0D. CALLing the address of the BRK instruction would cause an error to be raised. Update with example, as a runnable BBC BASIC program: 10 DIM b% 32 20 ?b%=0: REM BRK 30 ?(b%+1)=42: REM Error number 42 40 $(b%+2)="StackExchange"...


24

If you look at the screen clear code in the Applesoft BASIC ROM, you'll find this: f3f6 lda $e6 ;put base address of current hi-res page sta $1b ; into $1a/1b (will be $2000 or $4000) ldy #$00 sty $1a f3fe lda $1c ;get color value sta ($1a),y ;store it in frame buffer jsr $f47e ;...


24

The designers figured that you'd use X and Y for looping, indexing etc, and use A for adding and subtracting, shifts etc. So they saw a need for INX and INY, but didn't see a enough of a need for an instruction to increment or decrement the accumulator. That's also the reason why X and Y cannot participate in many ALU operations, like adds, shifts, and ...


24

You are in luck. The latest version of the 6502 is still manufactured and sold. You need to search for it by the official manufacturer's product code "W65C02S6TPG-14". Western Design Center (that first "W") licenses the manufacture of the chip to various silicon foundries, which wholesale them to dealers you can buy from online. If you don't use this recent ...


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