53

Coding in assembly is brutal. Rogue pointers Assembly languages rely even more on pointers (through address registers) so you can't even rely on the compiler or static analyzing tools to warn you about such memory corruptions / buffer overruns as opposed to C. For instance in C, a good compiler may issue a warning there: char x[10]; x[20] = 'c'; That's ...


39

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

All of them. But it will only have an effect with a select few. Contrary to what the question implies, the rep prefix is not an orthogonal looping construct that can be combined with any instruction. The 8086 family manual defines the use of rep/repe/repz (0xf3) and repne/repnz (0xf2) prefixes only in conjunction with string instructions, which are movs, ...


25

The standard way would be adding it to HL. After clearing HL that is. LD HL,0 ADD HL,SP Voila. This is not only already available with the 8080, DAD SP ; Same opcode (39h), same workings thus preferable, but as well very handy when setting up a pointer to parameters on stack as, of course, any other constant than 0 can be used and added. ...


24

I spent most of my career writing assembler, solo, small teams and large teams (Cray, SGI, Sun, Oracle). I worked on embedded systems, OS, VMs, and bootstrap loaders. Memory corruption was seldom if ever a problem. We hired sharp people, and the ones that failed were managed into different jobs more appropriate to their skills. We also tested fanatically - ...


21

The TLE instruction is a modification of the TLU instruction. TLU (Table LookUp) (Opcode 84) compared a word with a series of consecutive words on the drum and finished as soon as an entry was found being equal or higher. It was meant to find a point in a sorted list. TLE (Table Lookup Equal) (Opcode 63) is a modification of TLU stopping only when equal, ...


21

I managed to find the exact same three photos Stroustrup used in his slide: Simula: Kristen Nygaard, who co-designed Simula with Ole-Johan Dahl; Fortran: John Backus, who headed the team that developed Fortran; Assembler: David John Wheeler0, who worked on what would today be called a relocating assembler for the EDSAC, an early programmable computer (paper)...


20

I'm going to say "No" simply because the 8086 doesn't support the alternate registers of the Z80. That was a fairly important concept that you can not directly mimic on the 8086. Mind, if you're willing to dedicate memory and whatnot to support it, then, "sure". Replace the Z80 functionality with a macro, say. But now you're stretching it....


19

I'm working on implementing the instructions of the z80 chip inside a gameboy for an emulator. Well, I guess that's the most important point here: The Gameboy doesn't feature a Z80, but an independent 8080 descendant. Using a Z80 opcode table will not get you anywhere. It's LR35902 CPU (*1) is, like the Z80, based on the 8080 with some extensions. The ...


19

According to this answer gcc does this because of the proliferation of different object file formats: x86-64 processor alone uses ELF, PE/COFF, MachO64. But other compilers (e.g. clang) go straight to object files without using an intermediate assemble step, so I would disagree that an assemble step is "now ubiquitous".


19

Simple idiotic errors abound in assembly, no matter how careful you are. It turns out that even stupid compilers for poorly-defined high level languages (like C) constrain a huge range of possible errors as semantically or syntactically invalid. A mistake with a single extra or forgotten keystroke is far more likely to refuse to compile than it is to ...


18

The difference is that the latter appeared in DOS 2.0. MS-DOS 1.x was pretty much a rebranded version of Seattle Computer Products’ 86-DOS (initially named QDOS), which in turn was heavily inspired by CP/M. One of the design goals of 86-DOS has been to maintain a certain level of compatibility with CP/M-80: specifically, to be able to port CP/M software to ...


16

Early Unix C compilers were actually a pipeline, preprocessor | compiler | optimizer | assembler > abc.o. The optimizer was an assembly optimizer, doing things like fixing up things that the compiler took the easy way on, like subroutine entry and exit, and deciding between a short or a long jump (PDP-11s had short conditional branch instructions). Having ...


14

I wrote the original garbage collector for MDL, a Lisp like language, back in 1971-72. It was quite a challenge for me back then. It was written in MIDAS, an assembler for the PDP-10 running ITS. Avoiding memory corruption was the name of the game in that project. The entire team had dread of a successful demo crashing and burning when the garbage ...


13

Since it's two questions, here are two answers: Adressing Issue It's a very BASIC 65xx to x80 transition error: Index Registers Where 65xx CPUs use a 16 it base address (from memory) and an 8 bit index (from register), the x80s use 16 bit index register(s) and an (optional) 8 bit offset. The address of msg should be loaded into IY first (LD IY,msg) and then ...


12

Preface, this is not really how RC.SE works. If you're looking for someone to design your hardware or write you a program, there are many sites out there where you can put a reward for someone taking the job. RC.SE is about answering your questions, as detailed as they are asked I am working on designing a Z80 computer and I would like to use a PS/2 ...


12

The V1 Unix B manpage uses .s as the extension for intermediate assembly files used during the build. This is the earliest use of .s that I can find, and would correspond to November 1971 at the latest. There were assemblers on systems with file systems before Unix, but none that I’m aware of used .s. Some like DECsys don’t appear to have extensions; other ...


12

On the 8088 and 8086, execution involves two parallel processes--memory access and internal computation--and will be limited by the speed of whichever is slower. Generally, on the 8088 execution speed will be limited by memory access, while the 8086 will be better balanced. Every memory cycle on the 8088 or 8086 takes a minimum of four cycles, and on most ...


12

Since the inline assembler of cc65 doesn't accept anonymous labels (from my other answer), another approach is to provide a unique suffix to the labels, which can be applied by the macro. The stringizing operator of the C preprocessor, and the fact that C string literals written consecutively are automatically concatenated, might make this more convenient: #...


12

The problem with Z80ASM specifically is that it takes the assembly input and spits out a static binary file. This is good and bad. In "normal" systems, address assignment is, inevitably, the responsibility of the linker, not the assembler. But assemblers are simple enough that many skip that aspect of the build cycle. Since Z80ASM spits out literal ...


12

The Japanese children's book The Stars of Famicom Games includes pictures of Super Mario Brothers 3 development for the NES/Famicom. Code was written on an HP 64000 Logic Development System and cross assembled. See also: NES (Famicom) Development Kit Hardware


12

The 1955 manual for the IBM 704 on page 7 talks about data representation in the computer. When a word is interpreted as numerical data, the zero position acts as the sign of the word. (…) When a logical operation is performed on a word, the word is interpreted as a 32-bit signless number. As an algebraic (signed) binary number, a word can represent (…) In ...


11

Note: this is mostly guesswork I don't know this assembler but the f suffix seems to denote a label. Example bec 1f jmp cerror 1: Those instructions write the parameters in the parameter zone of the system call. mov 6(r5),0f mov 8(r5),0f+2 note that there's a 0 label just after the sys instruction. It holds the parameters (copies of those which ...


11

In Kick Assembler you can put labels in front of opcode arguments. For example you can write your raster interrupt like: raster_interrupt: lda bgnd_color:#$00 sta $d021 ; rest of interrupt handler and change the color elsewhere in your program with: lda #$01 sta bgnd_color Such labels in front of the argument provide a more compact ...


11

If I was to write an Amiga game, what would be the best/most reliable way to detect how much RAM is actually available? The routine you're quoting is only able to detect chip memory (not fast memory), by hardware banging in certain areas. Games sometimes tried $C00000 (popular slow memory location) in the same fashion. But there are too many fast memory ...


11

You can't repeat arbitrary instructions with rep. In asm syntax, rep just means to include an F3 byte as a prefix for this instruction. There is no implication that it actually means repeat, it's just shorthand for db 0xF3. Assemblers exist to help you put the bytes you want into an object file. It's up to you to make good choices. When F3 rep doesn't ...


11

My question is, why did they use an LD B, B instruction, and not a proper NOP? LD B,B works like a NOP - at least as stated in the original 8080 manual (*1): The original 8080 had 8 NOPs at 00xxx000 but only the first was defined as 'the nop'. In addition there were 7 instructions of loading a register with itself (*2). Effective NOPs, but not defined as ...


11

Without reading the manuals it seems that both vasm and tasm decides if an operand is a number or a label is decided from the first character. A number MUST start with a digit in the decimal range, anything starting with a letter is considered a label. So you need to enter the number as '0A000H'. So, when tasm finds an argument A000H it thinks it a label ...


10

I think that some of the existing answers are using the modern state of development ecosystems to address the state of things in the "retro" time. I don't recall using anything other than a.out format until the mid-90s, and the switch was driven by shared libraries (which I wouldn't call retro). You need to think in terms of not being able to download ...


10

I am afraid that the answer is "it could take any time, depending on circumstances and the real WAIT condition". WAIT states have unpredictable length, so there is no exact way to answer your question. The general answer, theoreticaly valid for every CPU (and really valid for the most of 8bit CPUs), is: Take an "instruction timing chart" ...


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