CS代考

Introduction to Assembly Language and Operating systems
CHAPTER 1: BASIC CONCEPTS
IRVINE, KIP R. ASSEMBLY LANGUAGE FOR INTEL-BASED COMPUTERS 7/E, 2015.

Copyright By PowCoder代写 加微信 powcoder

IRVINE, KIP R. ASSEMBLY LANGUAGE FOR INTEL-BASED COMPUTERS 7/E, 2015.

Chapter Overview
Welcome to Assembly Language
Virtual Machine Concept
Data Representation
Boolean Operations

Welcome to Assembly Language
Why learn AL?

Device drive and embedded programming
Telephone, security system, video card, sound card, AC control systems etc.
Simulation/Monitoring
Real-time applications dealing with simulation and hardware monitoring require precise timing and responses.
High-level languages do not give programmers exact control over machine code generated by compilers.
Assembly language permits you to precisely specify a program’s executable code
Game and real-time apps
Software need to be highly optimized for small code size and fast execution.
Assembly language permits direct access to computer hardware, and code can be hand optimized for speed
Understanding Hardware, OS, and Apps
Assembly language helps you to gain an overall understanding of the interaction between computer hardware, operating systems, and application programs.

Assembly Language Applications
Large application programs rarely coded completely in assembly language
Assembly language code would take too much time to write and maintain.
Assembly language is used to optimize certain sections of application programs for speed and to access computer hardware
Some representative types of applications:

Business application for single platform
Hardware device driver
Business application for multiple platforms
Embedded systems & computer games

Virtual Machine Example: JVM
JVM, the main component of Java architecture and the part of JRE. Provides the cross platform functionality to java.
A software process that converts the compiled Java byte code to machine code.
Byte code is an intermediary language between Java source and the host system.

http://en.wikipedia.org/wiki/Java_virtual_machine

Virtual Machine Example: .NET CLR
Common Language Runtime (CLR) is the virtual machine of Microsoft’s .NET framework, responsible for managing the execution of .NET programs.
A process known as just-in-time (JIT) compilation, the CLR compiles the intermediate language code (CIL) into the machine instructions executed by the computer’s CPU.

http://en.wikipedia.org/wiki/.NET_Framework

Virtual Machines
Programming Language analogy:

Each computer has a native machine language (language L0) that runs directly on its hardware
A more human-friendly language is usually constructed above machine language, called Language L1
Programs written in L1 can run two different ways:

Interpretation – L0 program interprets and executes L1 instructions one by one
Translation – L1 program is completely translated into an L0 program, which then runs on the computer hardware

Translating Languages
English: Display the sum of A times B plus C.
C++: cout << (A * B + C); Assembly Language: call WriteInt Intel Machine Language: A1 00000000 F7 25 00000004 03 05 00000008 E8 00500000 one to many one to one Specific Machine Levels High-Level Language Application-oriented languages C++, Java, Pascal, Visual Basic . . . powerful statements that translate into multiple assembly language instructions Programs compile into assembly language (Level 4) Assembly Language Instruction mnemonics (such as ADD, SUB, and MOV) Have a one-to-one correspondence to machine language Programs are translated into Instruction Set Architecture Level - machine language (Level 2) Assembly language programs are translated (assembled) in their entirety into machine language before they begin to execute Instruction Set Architecture (ISA) Also known as conventional machine language First level at which users can write programs The programs consist of binary values called machine language. Each machine-language instruction is executed Directly by the computer’s hardware or by a program embedded in the microprocessor chip called a microprogram Executed by Level 1 (Digital Logic) Digital Logic Hardware CPU, constructed from digital logic gates System bus Implemented using bipolar transistors next: Data Representation Data Representation Binary Numbers Translating between binary and decimal Binary Addition Integer Storage Sizes Hexadecimal Integers Translating between decimal and hexadecimal Hexadecimal subtraction Signed Integers Binary subtraction Character Storage Digits for the Numbering in Hardware and Software Manuals Binary Numbers Computer stores instructions and data in memory as collections of electronic charges on/off Digits are 1 and 0, called bit Bits are numbered sequentially starting at zero on the right side and increasing toward the left. MSB – most significant bit LSB – least significant bit 658.unknown Binary Numbers Each digit (bit) is either 1 or 0 Each bit represents a power of 2: 659.unknown Translating Binary to Decimal Weighted positional notation shows how to calculate the decimal value of each binary bit: dec = (Dn-1  2n-1) + (Dn-2  2n-2) + ... + (D1  21) + (D0  20) D = binary digit, 0 or 1 binary 00001001 = decimal 9: (1  23) + (1  20) = 9 Translating Binary to Decimal Horner's rule: http://en.wikipedia.org/wiki/Horner’s_rule dec =((…( (Dn-1  2) + Dn-2) 2) + ... + D1) 2 + D0 10001001b = 128 +8 +1 = 137d dec =((…( (D7  2) + D6) 2) + ... + D1) 2 + D0 = ((…( (1  2) + 0) 2) + ... + 0) 2 + 1 Good for code implementation Example: 10010101101b  1197d Translating Unsigned Decimal to Binary Repeatedly divide the decimal integer by 2. Each remainder is a binary digit in the translated value: 37 = 100101 Binary Addition Starting with the LSB, add each pair of digits, include the carry if present. In Binary: 2 represented as 1 0 666.unknown Integer Storage Sizes What is the largest unsigned integer that may be stored in 20 bits? Standard sizes: 667.unknown Hexadecimal Integers Binary values are represented in hexadecimal. Translating Binary to Hexadecimal Each hexadecimal digit corresponds to 4 binary bits. Example: Translate the binary integer 101101010011110010100 to hexadecimal: Try to separate: 0001,0110,1010,0111,1001,0100 Converting Hexadecimal to Decimal Multiply each digit by its corresponding power of 16: dec = (D3  163) + (D2  162) + (D1  161) + (D0  160) Hex 1234 equals (1  163) + (2  162) + (3  161) + (4  160), or decimal 4,660. Hex 3BA4 equals (3  163) + (11  162) + (10  161) + (4  160), or decimal 15,268. Horner's rule: (((3  16) + 11)  16) + 10 ) 16) + 4 Powers of 16 Converting Decimal to Hexadecimal decimal 422 = 1A6 hexadecimal Hexadecimal Addition Divide the sum of two digits by the number base (16). The quotient becomes the carry value, and the remainder is the sum digit. 36 28 28 6A 42 45 58 4B 78 6D 80 B5 21 / 16 = 1, rem 5 Hexadecimal Subtraction When a borrow is required from the digit to the left, add 16 (decimal) to the current digit's value: 16 + 5 = 21 Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive If the highest digit of a hexadecimal integer is > 7, the value is negative. Examples: 8A, C5, A29D, B1234567
What’s this?

668.unknown

Forming the Two’s Complement
Negative numbers are stored in two’s complement notation
Represents the additive Inverse

Note that 00000001 + 11111111 = 00000000
Two’s Complement operation is reversible. Two’s Complement of 11111111 is 00000001

Binary Subtraction
When subtracting A – B, convert B to its two’s complement
Add A to (–B)

0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0
– 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1
0 0 0 0 1 0 0 1

Learn How To Do the Following:
Form the two’s complement of a hexadecimal for (-27197d)
Convert signed binary to decimal
Convert signed decimal to binary
Convert signed decimal to hexadecimal
Convert signed hexadecimal to decimal

 95C2h+1 95C3h
 00001111+1  -16d
(43d  00101011b, 11010100b+1)  11010101b
(2Ah+1 = 2Bh) -43d

Ranges of Signed Integers
The highest bit is reserved for the sign. This limits the range:
10000000 – 01111111

Character Storage
Character sets : mapping of characters to integers
Standard ASCII (0 – 127)
ASSCI: American Standard Code for Information Interchange
Unique 7-bit integer is assigned to each character
Extended ASCII (0 – 255)
The extra bit is used on various computers to create a proprietary character set
IBM use values 128 through 255 represent graphics symbols and Greek characters
ANSI (0 – 255)
ANSI: American National Standards Institute
The first 128 characters correspond to the letters and symbols on a standard U.S. keyboard.
The second 128 characters represent special characters such as letters in international alphabets, accents, currency symbols, and fractions.
http://en.wikipedia.org/wiki/ASCII

Character Storage
Character sets : mapping of characters to integers
Unicode (0 – 65,535)
Universal way of defining characters and symbols
Represent a wide variety of international languages in computer software.
Defines codes for characters, symbols, and punctuation used in all major languages
European alphabetic scripts, Middle Eastern right-to-left scripts, and many scripts of Asia
Null-terminated String
It is a string of characters followed by a single byte containing zero.
Array of characters followed by a null byte
The C and C++ languages use null terminated strings, and many DOS and Windows functions require strings to be in this format.

Boolean Algebra
Based on symbolic logic, designed by
http://en.wikipedia.org/wiki/George_Boole
Boolean expressions created from:
NOT, AND, OR

Inverts (reverses) a Boolean value
Truth table for Boolean NOT operator:

Digital gate diagram for NOT:

Truth table for Boolean AND operator:

Digital gate diagram for AND:

Truth table for Boolean OR operator:

Digital gate diagram for OR:

Operator Precedence
Examples showing the order of operations:

Truth Tables (1 of 3)
A Boolean function has one or more Boolean inputs and returns a single Boolean output.
A truth table shows all the inputs and outputs of a Boolean function

Example: X  Y

Truth Tables (2 of 3)
Example: X  Y

Truth Tables (3 of 3)
Example: (Y  S)  (X  S)

http://en.wikipedia.org/wiki/Multiplexer
Two-input multiplexer

Assembly language helps you learn how software is constructed at the lowest levels
Assembly language has a one-to-one relationship with machine language
Boolean expressions are essential to the design of computer hardware and software

1 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0

bit position:

doubleword

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com