Assembly Language


Summary

This web page examines the use of registers in assembly language. Specific examples of registers from various processors are used to illustrate the general nature of assembly language.

Register set

 

Registers are fast memory, almost always connected to circuitry that allows various arithmetic, logical, control, and other manipulations, as well as possibly setting internal flags.

Most early computers had only one data register that could be used for arithmetic and logic instructions. Often there would be additional special purpose registers set aside either for temporary fast internal storage or assigned to logic circuits to implement certain instructions. Some early computers had one or two address registers that pointed to a memory location for memory accesses (a pair of address registers typically would act as source and destination pointers for memory operations). Computers soon had multiple data registers, address registers, and sometimes other special purpose registers. Some computers have general purpose registers that can be used for both data and address operations. Every digital computer using a von Neumann architecture has a register (called the program counter) that points to the next executable instruction. Many computers have additional control registers for implementing various control capabilities. Often some or all of the internal flags are combined into a flag or status register.

Accumulators


Accumulators are registers that can be used for arithmetic, logical, shift, rotate, or other similar operations. The first computers typically only had one accumulator. Many times there were related special purpose registers that contained the source data for an accumulator. Accumulators were replaced with data registers and general purpose registers. Accumulators reappeared in the first microprocessors.

  • Intel 8086/80286: one word (16 bit) accumulator; named AX (high order byte of the AX register is named AH and low order byte of the AX register is named AL)

  • Intel 80386: one doubleword (32 bit) accumulator; named EAX (low order word uses the same names as the accumulator on the Intel 8086 and 80286 [AX] and low order and high order bytes of the low order words of four of the registers use the same names as the accumulator on the Intel 8086 and 80286 [AH and AL])

  • MIX: one accumulator; named A-register; five bytes plus sign

 

Data registers


Data registers are used for temporary scratch storage of data, as well as for data manipulations (arithmetic, logic, etc.). In some processors, all data registers act in the same manner, while in other processors different operations are performed are specific registers.

  • MIX: one extension register; named X-register; five bytes plus sign; can be concatenated on the right hand side of the A-register (accumulator)

  • Motorola 680x0, 68300: 8 longword (32 bit) data registers; named D0, D1, D2, D3, D4, D5, D6, and D7

 

Address registers


Address registers store the addresses of specific memory locations. Often many integer and logic operations can be performed on address registers directly (to allow for computation of addresses).

Sometimes the contents of address register(s) are combined with other special purpose registers to compute the actual physical address. This allows for the hardware implementation of dynamic memory pages, virtual memory, and protected memory.

The number of bits of an address register (possibly combined with information from other registers) limits the maximum amount of addressable memory. A 16-bit address register can address 64K of physical memory. A 24-bit address register can address address 16 MB of physical memory. A 32-bit address register can address 4 GB of physical memory. A 64-bit address register can address 1.8446744 x 1019 of physical memory. Addresses are always unsigned binary numbers.

  • MIX: one jump registers; named J-register; two bytes and sign is always positive

  • Motorola 680x0, 68300: 8 longword (32 bit) address registers; named A0, A1, A2, A3, A4, A5, A6, and A7 (also called the stack pointer)

 

General purpose registers


General purpose registers can be used as either data or address registers.

  • DEC VAX: 16 word (32 bit) general purpose registers; named R0 through R15

  • IBM 360/370: 16 full word (32 bit) general purpose registers; named 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A (or 10), B (or 11), C (or 12), D (or 13), E (or 14), and F (or 15)

  • Intel 8086/80286: 8 word (16 bit) general purpose registers; named AX, BX, CX, DX, BP, SP, SI, and DI (high order bytes of the AX, BX, CX, and DX registers have the names AH, BH, CH, and DH and low order bytes of the AX, BX, CX, and DX registers have the names AL, BL, CL, and DL)

  • Intel 80386: 8 doubleword (32 bit) general purpose registers; named EAX, EBX, ECX, EDX, EBP, ESP, ESI, and EDI (low order words use the same names as the general purpose registers on the Intel 8086 and 80286 and low order and high order bytes of the low order words of four of the registers use the same names as the general purpose registers on the Intel 8086 and 80286)

  • Motorola 88100: 32 word (32 bit) general purpose registers; named r0 through r31

 

Constant registers


Constant registers are special read-only registers that store a constant. Attempts to write to a constant register are illegal or ignored. In some RISC processors, constant registers are used to store commonly used values (such as zero, one, or negative one) — for example, a constant register containing zero can be used in register to register data moves, providing the equivalent of a clear instruction without adding one to the instruction set. Constant registers are also often used in floating point units to provide such value as pi or e with additional hidden bits for greater accuracy in computations.

  • Motorola 88100: r0 (general purpose register 0) contains the constant 32 bit integer zero

 

Floating point registers


Floating point registers are special registers set aside for floating point math.

Index registers


Index registers are used to provide more flexibility in addressing modes, allowing the programmer to create a memory address by combining the contents of an address register with the contents of an index register (with displacements, increments, decrements, and other options). In some processors, there are specific index registers (or just one index register) that can only be used only for that purpose. In some processors, any data register, address register, or general register (or some combination of the three) can be used as an index register.

  • IBM 360/370: any of the 16 general purpose registers may be used as an index register

  • Intel 80x86: 7 of the 8 general purpose registers may be used as an index register (the ESP is the exception)

  • MIX: five index registers; named I-registers I1, I2, I3, I4, and I5; five bytes plus sign

  • Motorola 680x0, 68300: any of the 8 data registers or the 8 address registers may be used as an index register

 

Base registers


Base registers or segment registers are used to segment memory. Effective addresses are computed by adding the contents of the base or segment register to the rest of the effective address computation. In some processors, any register can serve as a base register. In some processors, there are specific base or segment registers (one or more) that can only be used for that purpose. In some processors with multiple base or segment registers, each base or segment register is used for different kinds of memory accesses (such as a segment register for data accesses and a different segment register for program accesses).

  • IBM 360/370: any of the 16 general purpose registers may be used as a base register

  • Intel 80x86: 6 dedicated segment registers: CS (code segment), SS (stack segment), DS (data segment), ES (extra segment, a second data segment register), FS (third data segment register), and GS (fourth data segment register)

  • Motorola 680x0, 68300: any of the 8 address registers may be used as a base register

 

Control registers


Control registers control some aspect of processor operation. The most universal control register is the program counter.

Program counter


Almost every digital computer ever made uses a program counter. The program counter points to the memory location that stores the next executable instruction. Branching is implemented by making changes to the program counter. Some processor designs allow software to directly change the program counter, but usually software only indirectly changes the program counter (for example, a JUMP instruction will insert the operand into the program counter). An assembler has a location counter, which is an internal pointer to the address (first byte) of the next location in storage (for instructions, data areas, constants, etc.) while the source code is being converted into object code.

The VAX uses the 16th of 16 general purpose registers as the program counter (PC). Almost the entire instruction set can directly manipulate the program counter, allowing a very rich set of possible kinds of branching.

The program counter in System/360 and 370 machines is contained in bits 40-63 of the program status word (PSW), which is directly accessible by some instructions.

  • IBM 360/370: program counter is bits 40-63 of the program status word (PSW)

  • Intel 8086/80286: 16-bit instruction pointer (IP)

  • Intel 80386: 32-bit instruction pointer (EIP)

  • Motorola 680x0, 68300: 32-bit program counter (PC)

 

Processor flags


Processor flags store information about specific processor functions. The processor flags are usually kept in a flag register or a general status register. This can include result flags that record the results of certain kinds of testing, information about data that is moved, certain kinds of information about the results of compations or transformations, and information about some processor states. Closely related and often stored in the same processor word or status register (although often in a privileged portion) are control flags that control processor actions or processor states or the actions of certain instructions.

  • IBM 360/370: program status word (PSW)

  • Intel 8086/80286: 16-bit flag register (FLAGS); system flags, control flag, and status flags)

  • Intel 80386: 32-bit flag register (EFLAGS); system flags, control flag, and status flags)

  • MIX: an overflow toggle and a comparison indicator

  • Motorola 680x0, 68300: 16-bit status register (SR); high byte is system byte and requires privileged access, low byte is user byte or condition code register (CCR)

A few typical result flags (with processors that include them):

  • auxilary carry Set if a carry out of the most significant bit of a BCD operand occurs (binary coded decimal addition). Also commonly set if a borrow occurs in a BCD subtract. Used in Intel 80x86 [AF].

  • carry Set if a carry out of the most significant bit of an operand occurs (addition). Also commonly set if a borrow occurs in a subtract. Used in Digital VAX [C], Intel 80x86 [CF], Motorola 680x0 [C], Motorola 68300 [C], Motorola M68HC16 [C].

  • comparison indicator contains one of three values: less, equal, or greater. Used in MIX.

  • extend Set to the value of the carry bit for arithmetic operations (used to support implementation of multi-byte arithmetic larger than that implemented directly by the hardware. Used in Motorola 680x0 [X], Motorola 68300 [X].

  • half carry Set if a carry out of bit 3 of an operand occurs during BCD addition. Used in Motorola M68HC16 [H].

  • negative Set if the most significant bit of a result is set. Used in Digital VAX [N], Motorola 680x0 [N], Motorola 68300 [N], Motorola M68HC16 [N].

  • overflow Set if arithmetic overflow occurs. Used in Digital VAX [V], Intel 80x86 [OF], Motorola 680x0 [V], Motorola 68300 [V], Motorola M68HC16 [V].

  • overflow toggle a single bit that is either on or off. Used in MIX.

  • parity For odd parity machines, set to make an odd number of one bits; for an even parity machine, set to make an even number of one bits. Used in Intel 80x86 [PF]. The IBM 360/370 has odd parity on memory.

  • sign Set for negative sign. Used in Intel 80x86 [SF].

  • trap Set for traps. Used in Intel 80x86 [TF].

  • zero Set if a result equals zero. Used in Digital VAX [Z], Intel 80x86 [ZF], Motorola 680x0 [Z], Motorola 68300 [Z], Motorola M68HC16 [Z].

Some conditions are determined by combining multiple flags. For example, if a processor has a negative flag and a zero flag, the equivalent of a positive flag is the case of both the negative and zero flags both simultaneously being cleared.

A few typical control flags (with processors that include them):

  • decimal overflow trap enable Set if decimal overflow occurs (or conversion error on a VAX). Used in Digital VAX [DV].

  • direction flag Determines the direction of string operations (set for autoincrement, cleared for autodecrement). Used in Intel 80x86 [DF].

  • floating underflow trap enable Set if floating underflow occurs. Used in Digital VAX [FU].

  • integer overflow trap enable Set if integer overflow occurs (or conversion error on a VAX). Used in Digital VAX [IV].

  • interupt enable Set if interrupts enabled. Used in Intel 80x86 [IF].

  • i/o privilege level Used to control access to I/O instructions and hardware (thereby seperating control over I/O from other supervisor/user states). Two bits. Used in Intel 80x86 [IO PL].

  • nested task flag Used in Intel 80x86 [NF].

  • resume flag Used in Intel 80x86 [RF].

  • virtual 8086 mode Used to switch to virtual 8086 emulation. Used in Intel 80x86 [VM].

 

Stack pointer

Stack pointers are used to implement a processor stack in memory. In many processors, address registers can be used as generic data stack pointers and queue pointers. A specific stack pointer or address register may be hardwired for certain instructions. The most common use is to store return addresses, processor state information, and temporary variables for subroutines.

  • IBM 360/370: any of the 16 general purpose registers may be used as a stack pointer

  • Intel 8086/80286: dedicated stack pointer (SP) combined with stack segment pointer (SS) to create address of stack

  • Intel 80386: dedicated stack pointer (ESP) combined with stack segment pointer (SS) and the stack-frame base pointer (EBP) to create address of stack

  • Motorola 680x0, 68300: dedicated user stack pointer (USP, A7) and system stack pointer (SSP, A7) for implicit stack pointer operations, as well as allowing any of the 8 address registers to be as explicit stack pointers

 

Subroutine return pointer


Some RISC processors include a special subroutine return pointer rather than using a stack in memory. The return address for subroutine calls is stored in this register rather than in memory. More than one level of subroutine calls requires storing and saving the contents of this register to and from memory.

  • Motorola 88100: r1 is a 32 bit register containing the return pointer generated by bsr and jsr instructions; the register can be read or overwritten by software and can even be used as a temporary general purpose data register

Operating systems Initial Release and Release dates


Old and reliable


The potential advantage of an older operating system is that it has had years of heavy use that has led to greater dependability and fewer bugs and crashes.

Of course, this only applies if the maker of the operating system has put effort into bug fixes.

As an example, the programmers working on LINUX invest huge effort into ridding their operating system of even the smallest bugs, while Microsoft (Windows) has the policy of ignoring bug fixes unless the bugs affect a substantial percentage of their customers. Some cynical observers believe that Microsoft intentionally includes bugs to increase the profitability of their paid technical support services.

Bill Gates, when questioned about the more than 10,000 known bugs Microsoft acknowledged existed in Windows 98, claimed “There are no significant bugs in our released software that any significant number of users want fixed.…The reason we come up with new versions is not to fix bugs.…It’s the stupidest reason to buy a new version I ever heard.”

Another potential advantage of an older operating system is the existence of a larger library of available programs.

New and advanced


The potential advantage of a new operating system is that it can introduce important new ideas or techniques without the "drag" of supporting legacy software.

BeOS is an example of a new operating system built with the specific intent of being able to incorporate all new ideas and techniques.

NeXT is an example of an operating system that is fairly old but has some of the most modern and advanced features of any operating system available (especially Yellow Box, Web Objects, and EOF). Rhapsody (also known as Mac OS X Server) incorporates the dependability and new ideas of NeXT with the ideas from the revolutionary Macintosh OS.


1.1 MB QuickTime movie of Bill Gates explaining his criteria for selecting the best operating system.

(Transcribed below for those who don’t want to take the download time to see the video clip)

 “To create a new standard, it takes something that’s not just a little bit different, it takes something that’s really new and really captures people’s imagination and the Macintosh, of all the machines I’ve ever seen, is the only one that meets that standard.” — Bill Gates

Initial Release


The following chart shows the release dates of the first version of each listed operating system, with operating systems listed in chronological order:

1975
VAX/VMS Conception (June)

1977
VAX/VMS First VAX Ship date (October)

1978
VMS V1.0 (August)

1981
IBM-PC (Apr 24)
PC-DOS 1.0 (Aug 12)

1983
Amiga OS

1984
ULTRIX
Macintosh (January)

1985
Amiga OS 1.0 (October)

1986
HP-UX

1987
OS/2 (April 2)
OS/2 1.0 (December)

1993
FreeBSD 1.0 (December)

1995
BeOS (October)

2002
Syllable 2003 (July)

2003
Windows Server 2003 (April 24)

 

Release dates


The following chart shows the release dates of each version of each listed operating system, in chronological order:

1975
VAX/VMS Conception (June)

1977
VAX/VMS First VAX Ship date (October)

1978
VMS V1.0 (August)

1980
VMS V2.0 (April)

1981
IBM-PC (Apr 24)

1982
VMS V3.0 (April)
IBM PC-DOS version 1.1 (May 7)

1983
VMS VAXCLUSTERS announced
AmigaOS 1.0

1984
ULTRIX V1.0
Macintosh (January)
VMS V4.0 (September)
MicroVMS announced with VAX/VMS 4.0 (December)

1985
VMS V4.2
AmigaOS 1.0 (October)

1986
VMS V4.4e84
MicroVMS retired with VAX/VMS 4.4 (December)
HP-UX 1.0
VMS V4.7

1987
OS/2 1.0 (December)
HP-UX 1.1
HP-UX 1.2

1988
VMS V5.0 (May)
HP-UX 2.0
HP-UX 2.1
HP-UX 3.0

1989
VMS V5.2 (September)
HP-UX 3.1
HP-UX 7.0

1990
Windows 3.0 (May 22)
VMS V5.4 (October)
AIX 3.0
HP-UX 7.02
HP-UX 7.06
HP-UX 7.08

1991
VMS V5.5 (November)
VMS V5.5-1 (November)
VMS V5.5-2 (November)
OpenVMS name change of VMS to OpenVMS
HP-UX 8.0
HP-UX 8.01
HP-UX 8.02
HP-UX 8.06+
HP-UX 8.06
HP-UX 8.05
HP-UX 8.07

1992
OpenVMS Alpha V1.0; based on VAX/VMS 5.4 (November)
HP-UX 9.0
HP-UX 9.01

1993
BSDi BSD/OS initial production release (March)
OpenVMS VAX V6.0 (June)
FreeBSD 1.0 (December)
OpenVMS ALPHA V1.5
HP-UX 9.02
HP-UX 9.03

1994
OpenVMS VAX 6.1 (April)
OpenVMS ALPHA 6.1 (May)
FreeBSD 1.1 (May)
HP-UX 9.04
HP-UX 9.05

1995
FreeBSD 2.0 (January)
OpenVMS VAX 6.2 (May)
OpenVMS ALPHA 6.2 (June)
FreeBSD 2.0.5 (June)
BeOS (October), “Be publicly shows the BeOS for the first time. At that time, Be builds a proprietary hardware called the BeBox (which is a dual PowerPC machine, roughly a boosted PReP machine).”

ULTRIX V4.5 (November)
OpenVMS 7.0 (December)
HP-UX 9.07
HP-UX 10.0
HP-UX 10.01

1996
BeOS Dr6 (developer release): (January)
BeOS Dr7 (developer release): (April)
FreeBSD 2.1.5 (August)
BeOS Dr8 (developer release): (September)
OS/2 4.0 (September)
FreeBSD 2.2 (November) — “branched from the development mainline”
OpenVMS 7.1 (December)
HP-UX 10.10
HP-UX 10.20

1997
FreeBSD 2.1.7.1 (February) — “end of mainstream development on 2.1-stable”
FreeBSD 2.2.1 (April) — “first full release of 2.2 [series]”
BeOS Advanced Access Preview Release: (May)
BeOS PR (preview release): (July)
AIX 4.3 (October)
BeOS PR2 (preview release): (October)
HP-UX 10.30
HP-UX 11.00w

1998
BeOS Release 3 for Intel x86: (March)
BeOS Release 3 for PowerPC: (April)
BeOS Release 3.1: (June)
BeOS Release 3.2: (July)
FreeBSD 2.2.7 (July)
AIX 4.3.2 (October 5)
Macintosh 8. 5 (October)
FreeBSD 3.0 (October) — “first official 3.0 release”
FreeBSD 2.2.8 (November) — “the last release on the 2.2 branch”

1999
AIX 4.3.3 (October)

2000
Windows 2000 1.0 (February 17)
HP-UX 11.11 (aka 11i)
Macintosh OS X public beta (September 13)

2001
Macintosh OS X 10.0 (March 24)

2002
Syllable 2003 (July)

2003
Windows Server 2003 (April 24)