Docsity

Operating systems notes, Summaries of Operating Systems

Partial preview of the text

Download Operating systems notes and more Summaries Operating Systems in PDF only on Docsity!

Computer Organization and

Assembly Language

Lecture- 5- Machine Level Programming- II

Muhammad Hafeez

Department of Computer Science

GC University Lahore

Data Formats

Due to its origins as a 16-bit architecture that

expanded into a 32-bit one, Intel uses the term

“word” to refer to a 16-bit data type.

Based on this, they refer to 32-bit quantities as

“double words.”

They refer to 64-bit quantities as “quad words.”

Most instructions we will encounter operate on

bytes or double words.

Data Formats

More recent extensions of the C language

include the data type long long, which is

represented using 8 bytes.

However, IA32 does not support this data type

in hardware. But, the compiler must generate

sequences of instructions that operate on

these data 32 bits at a time

Data Formats

More recent extensions of the C language

include the data type long long, which is

represented using 8 bytes.

However, IA32 does not support this data type

in hardware. But, the compiler must generate

sequences of instructions that operate on

these data 32 bits at a time

Data Formats

Floating-point numbers come in three different forms: single-precision (4-byte) values, corresponding to C data type float Double-precision (8-byte) values, corresponding to C data type double; Extended-precision (10-byte) values . Gcc uses the data type long double to refer to extended- precision floating-point values. It also stores them as 12- byte quantities to improve memory system performance, as will be discussed later. Using the long double data type (introduced in ISO C99) gives us access to the extended-precision capability of x86.

Data Formats

Floating-point numbers come in three different forms: single-precision (4-byte) values, corresponding to C data type float Double-precision (8-byte) values, corresponding to C data type double; Extended-precision (10-byte) values . Gcc uses the data type long double to refer to extended- precision floating-point values. It also stores them as 12- byte quantities to improve memory system performance, as will be discussed later. Using the long double data type (introduced in ISO C99) gives us access to the extended-precision capability of x86.

Data Formats

Accessing Information

An IA32 central processing unit (CPU) contains a set of eight registers storing 32-bit values. These registers are used to store integer data as well as pointers. Their names all begin with %e, but otherwise, they have peculiar names. With the original 8086, the registers were 16 bits and each had a specific purpose. The names were chosen to reflect these different purposes. With flat addressing, the need for specialized registers is greatly reduced.

Accessing Information

The final two registers (%ebp and %esp) contain pointers to important places in the program stack. They should only be altered according to the set of standard conventions for stack management. The low-order 2 bytes of the first four registers can be independently read or written by the byte operation instructions.

Accessing Information

This feature was provided in the 8086 to allow backward compatibility to the 8008 and 8080—two 8- bit microprocessors that date back to 1974. When a byte instruction updates one of these single- byte “register elements,” the remaining 3 bytes of the register do not change. Similarly, the low-order 16 bits of each register can be read or written by word operation instructions. This feature stems from IA32’s evolutionary heritage as a 16-bit microprocessor and is also used when operating on integers with size designator short.

%rsp

x86-64 Integer Registers

Can reference low-order 4 bytes (also low-order 1 & 2 bytes)

%eax

%ebx

%ecx

%edx

%esi

%edi

%esp

%ebp

%r8d

%r9d

%r10d

%r11d

%r12d

%r13d

%r14d

%r15d

%r8

%r9

%r10

%r11

%r12

%r13

%r14

%r15

%rax

%rbx

%rcx

%rdx

%rsi

%rdi

%rbp

Operand Specifiers

Most instructions have one or more operands. specifying the source values and destination values performing an operation and the destination location into which to place the result . IA32 supports a number of operand forms. Source values can be given as constants or read from registers or memory. Results can be stored in either registers or memory.

Operand Specifiers

The second type, register, denotes the contents of one of the registers, either one of the eight 32-bit registers (e.g., %eax) for a double-word operation, one of the eight 16-bit registers (e.g., %ax) for a word operation, or one of the eight single-byte register elements (e.g., %al) for a byte operation.

Operand Specifiers

There are many different addressing modes allowing different forms of memory references. The most general form is Imm(E b ,E i ,s) Such a reference has four components: An immediate offset Imm, a base register E b , an index register E i , and a scale factor s. The s must be 1, 2, 4, or 8. The effective address is then computed as Imm + R[E b ]+ R[E i ]. s. This general form is often seen when referencing elements of arrays.