20192414 "Cyberspace Security Introduction," the third week of learning summary

Programming layer

Low-level programming language and pseudo-code

Computer operations

The computer is capable of storing, retrieving and programmable electronic device for processing data.

Storage, retrieval and processing operations of the computer can be performed on the data.

Machine language

Machine language: language instructions by a computer using binary coded direct configuration

Due to the limited number of instructions, the processor designers list all commands assigned to each instruction a binary code to represent them.

Very harmonious relationship between the processor and the instructions it can execute.

Each machine language instruction can only execute a very low-level tasks.

Pep8: a virtual machine

Machine code by different machines differ.

** virtual machine: the virtual machine to simulate the real important feature of the machine design.

Pep / 8 reflects important features

- memory consists of 65536 bytes of storage space, wordlength Pep / 8 is 2 bytes.

There are three focus register

• Program address calculator PC, which contains the next instruction to be executed

· A copy of the instruction register IR, which contains the instructions being executed

· Accumulator (a register)

Instruction format

An instruction consists of two parts, i.e., 8-bit and 16-bit instruction specifier specifier operands. Position command specifier described what to do and how to interpret operands. Operand specifier is the address of the operand or operand itself.

Instruction format specifier representing different numbers of bits used in a particular operation is different, operation code // // length ranging from 4 to 8 bits. 4 bit 5 bit opcode used to develop the use of which register. Register A (accumulator) register specifier is 0.

3-bit addressing mode of the operand specifier indicates what portion of the instruction parsing.

If yes 000, then the operand specifier of the instruction is stored in the operand identifier, called immediate addressing this addressing mode (i).

· If it is 001, then the operand specifier is stored in the memory operand address name is located. This addressing mode is a direct addressing (d).

No Number of instruction (data to be processed) into a meta-instruction operations

Some examples of instructions

0000 stop execution

1100 operand register A is loaded

1110 the contents of register A is stored in the operand

0111 was added to the operand register A

1000 subtracts the value of the operating values ​​in register A

01001 character input operator

01010 from the character output operand

A program instance

Manual simulation

· Read the next instruction from the development of the program counter position

· Decipher the instructions and update counter

· If necessary, get a few verses operation

· Execute instructions

Pep / 8 simulator '

Loader: software for reading a machine language and load it into the memory section

Assembly language

Assembly language instructions for each machine language instruction mnemonic is assigned a code, the program code instructions may be brilliant instead of binary numbers.

Assembler: translate assembly language program into machine code

Pep / 8 assembly language

STOP stop execution

The load register A LDA 008B

LDA contents loaded in the memory unit 8B register A

A STA in the contents of the register memory storage unit 8B

ADDA 008B was added to the register A

ADDA 8B, the contents of the memory unit register A is added

Assembler directive

The assembler program uses instruction translation

· ASCII representation of a string of ASCII bytes

`BLOCK create a byte block

· WORD create a word and store value into

· END represents the end of the assembler language program

Hello assembly language version of the program

Pep / 8 assembly language allows us to directly specify the character output, but also allows us to add a comment in the next instruction

Explanatory text notes to provide readers with the program

Assembly language program machine code input assembler program output

A new program

The most complicated is that we have to recognize here is in line with four memory cells associate.

It has a program loop

Read any number of values. We accomplish this by creating a function counting loop code.

Expression algorithm

We express the solution to every problem in narrative form, then write the code. In computing, planning solutions are called algorithms. Pseudo-code is a language that allows us to express algorithms in a clearer form.

Function pseudo-code

·variable

· Assignment

A variable value into the sum of

Set sum to 0 或sum<-1

Access sum value and the sum of

I am set to + 或 whether I <+ whether -sum

·input Output

We can use the Write statement input, input use Read the statement

Pseudo-code algorithm execution

While (quotient is not zero)

In addition to ten number system with a new base

As a result of the leftmost remainder of a

Replace the original decimal number using a commercially

Write pseudo-code algorithm

Desktop check: the whole design on paper walkthrough

Translation pseudo code algorithm

test

Test plan: documentation on how the test program

Code coverage (light box) Test Method: All statements tested by test method procedure or subroutine executing code

Data overlay (black box) Test Method: The code as a black box, based on the test method of testing all possible input data of the program or subroutine

Test Plan Implementation: prescribed test plan with test cases to verify whether or not a program expected results.

Problem solving and algorithm design

How to solve the problem

Ask a question

· Must understand the problem.

· Find the link between information and solutions. If you can not find a direct link, the blood may consider auxiliary problems. Ultimately, the solution should be.

·action plan

· Analysis of the resulting solution

Looking for familiar situations

In the case of identifying similar computer field it is useful.

Minute root treatment

A task can be divided into several sub-tasks and subtasks can continue to be divided into sub-tasks, so be it. It can be reused divide and conquer, until each sub-task are achievable so far.

algorithm

Algorithm: solve a problem or sub-problem with limited data for a limited time a clear set of instructions.

Computer problem solving process

Analysis and interpretation phase

analysis

Explanation

Algorithm development stage

Developing algorithms

Test algorithm

Implementation phase

coding

test

Maintenance phase

use

maintain

Methods

·analyse problem

List the main tasks

Preparation of the remaining modules

· Restructure and rewrite as necessary

Test algorithm

Simple algorithm parameters

With a choice of algorithm

IF.....

.....

ELSE IF...

......

Algorithm with cycle

Counting cycle algorithm

Three part test increment the loop control variable

Set count to 0

While(count<limit)

....

Set count to count+1

Event Control loop

Read a value

While (value>=0)

......

Read a value

...

Nested structure: the structure of another control structures embedded control structures, also known as nested logic.

Square root

Read in square

Calculate the square root

Write out square and the square root

`Calculate square root

Set epsilon to 1

WHILE(epsilon>0.001)

Calculate new guess

Set epsilom to abs

Abstract steps: Details not yet clear algorithm steps

Specific steps: completely unambiguous algorithm steps details

Complex Variables

Array

An array is a collection of famous isomorphic project

Project location in the collection is called index

integer numbers[10]

Write "Enter 10 integer numbers,one per line"

Set position to 0

WHILE (position<10)

Read in numbers[positon]

Set position to position+1

recording

Employee employee

Set employee.name to "Frank Jones"

Set emplpueea.age to 32

Search Algorithm

Sequential search

Set position to 0

Set found to FLASE

WHILE (position<10 AND found is FLASE)

IF(numbers[position]equals searchltem)

Set found to TRUE

ELSE

Set position to position + 1

Sequential search of an ordered array

Read in many of vlaues

Write "Enter value for which to search"

Read searchltem

Set found to TRUE if searchltem is there

IF (found)

Write "Item is found"

ELSE

Write "Item is not found"

Binary search

Binary search: found operating items in the ordered list, do most of the search range by comparing exclude wrong

Sequence

Selection Sort

Bubble Sort

Insertion Sort

Recursive algorithm

Recursive: the ability of the algorithm calls itself

Subroutine instructions

Recursive factorial

Recursive binary search

Quick Sort

Several important thought

Information hiding: the details hidden module to control access to these details of practice

Abstract: a model that the complex system, which includes only the details necessary for the observation of

Naming things

test

reward

Learn the simple machine language and assembly language

insufficient

English words inadequate reserves, represents the code can not read, can not read explanation

Guess you like

Origin www.cnblogs.com/yhr001/p/11722823.html