1、Introduction to Windows as a PlatformVisual Studio Express: Introduction to Windows as a PlatformAuthor: Rich TebbCompany: Content Master LtdIntroductionThe Visual Studio Express Editions family provides a free, lightweight, and easy-to-learn suite of programming tools that are aimed at the hobbyist
2、, novice, and student developer. Many people in this category will not have had any formal training in computer science, and indeed they may not have any programming experience at all. If you fall into this category, dont worry this guide is for you!This beginners guide is designed for people with l
3、ittle or no prior knowledge of computer programming, who want to create computer programs with the Visual Studio Express tools. If you already have significant programming experience, then you will probably not have much to learn from this article. So, what will you learn by reading through this gui
4、de? Well, if you want to write a program that you can run on your Microsoft Windows computer, this guide will introduce you to the fundamental concepts that will help you understand how to do just that. You will learn the answer to questions such as: How does a computer work? Whats the difference be
5、tween hardware and software? Whats an Operating System? How does a computer run my program? What are the component parts of a program?The purpose of this guide is to help you understand the environment in which a Microsoft Windows program runs. The way that a program works is affected by many factor
6、s including the computer that it runs on, the operating system, and the way that people will use the program. The environment of a computer program is called its platform. When you understand the programming environment, you will be able to appreciate how the computer interprets your programs, and a
7、s a result, learning to program will become easier and ultimately youll write better programs. This guide describes the Microsoft Windows platform as a programming environment. It applies to programs that run on Windows and are used by people that run Microsoft Windows these are called Windows appli
8、cations. If you want to write an application that people will access by using through their browser, then you need to create a Web application, not a Windows application. In that case, you should read the companion guide “Introduction to Web as a platform”, which provides information about the World
9、 Wide Web as an application platform.How Computers WorkAlthough computers consist of advanced technological components, the basic way a computer operates is very simple, and has changed very little since the invention of electronic computers in the middle of the twentieth century. A computer contain
10、s three main functional areas: Input/Output. This refers to any device attached to the computer that provides a means of interaction or communication between the computer and the outside world (from the computers perspective). Examples of input devices include the keyboard, mouse, and joystick. Exam
11、ples of output devices include the monitor, printer and soundcard. Memory. This is the part of the computer that provides information storage. A computers memory is divided into many thousands of small units called bytes. All the data that a computer manages is stored as one or more bytes. You can i
12、magine these bytes as slots or pigeonholes, each with its own memory location or address that the computer uses to fetch and store data, similar to a room full of Post Office boxes. Each box or byte contains a number that the computer can process. Central Processing Unit. The Central Processing Unit
13、 (CPU) is the brain of the computer, which performs all calculations and co-ordinates the operation of the memory and input/output devices.The Instruction CycleA computer operates by copying bytes from the memory or an input device onto the CPU, performing some calculations on those bytes, and then
14、copying the result of the calculations to the memory or an output device. This process continues in a cycle as shown below:For this cycle of data processing to be useful, the computer needs to have instructions that tell it what to read and write, and which calculations to perform. These instruction
15、s tell the CPU what memory location to read from (fetching data from memory) or write to (storing data to memory), and which input or output devices to access. (Later on in this article you will see how computer memory can hold information that represents external entities such as images or sound.)T
16、he instructions that a computer runs are simply numbers like any other data, and they are stored in the computers memory. The CPU always keeps an internal record of which memory location (address) contains the next instruction that it will execute. When it completes one instruction, it reads the nex
17、t instruction from memory, and updates its record to point to the instruction after that. After it has updated its record, it can process the instruction that it has just read from memory.So a computer program is just a series of bytes that contain instructions for the CPU. When the computer runs th
18、e program, it moves sequentially through the set of instruction bytes, loading each instruction onto the CPU, performing that instruction, and then going back to fetch the next instruction onto the CPU. The program itself does not always need to tell the CPU to move to the next instruction this happ
19、ens automatically. However, instructions can also tell the CPU to modify its internal record so that it will read the next instruction from a different address. These instructions, called jump instructions, enable the computer to perform different actions depending on the circumstances. Lets have a
20、look at how instructions work inside a computer, by taking some example instructions and seeing how the computer uses them.The diagram depicts several bytes of computer memory that contain CPU instructions (in the lower section) and data (in the upper section). In the lower section of memory depicte
21、d, the numerical values of the CPU instructions are displayed in blue text. Alongside the numerical value is a mnemonic representation of the CPU instructions in semi-readable text. Starting with the lowest memory location (at the bottom of the diagram) and reading upwards, the CPU instructions tell
22、 the CPU to perform the following actions:read 8000Read the value from address 8000 into the CPU.sub 100Subtract 100 from the value in the CPU (the result of the subtraction replaces the value just read into the CPU).cmp 121Compare the current value in the CPU to 121.jne +8If the CPU value is not eq
23、ual (jne stands for Jump Not Equal), jump forward by 8 bytes from the current instruction (to address 2020) and continue by executing the instruction contained at that memory location.If the CPU value is equal to 121, then the CPU would not jump, and it would continue to read its instructions from t
24、he next sequential memory location, which is 2016 in this example.jmp 2038Jump to address 2038 and continue by executing the instruction contained at that memory location.write 8842Write the value in the CPU to memory location 8842.Phew! It takes quite a leap of imagination to see how all this numbe
25、r processing could enable a computer to perform all the actions that we use from day to day, like word processing or browsing the Internet. Hang on youre through the most complicated part, but you still need a bit more information to help you make the leap.Challenge: As a quick challenge, see if you
26、 can work out what will happen in the example above. Assuming that the value at memory location 8000 contains the value 221, work through the CPU instructions and answer the following questions: What value gets written to memory location 8842? What value gets written to memory location 8878?You can
27、find the answers at the end of this article.Input and Output DevicesIf a computer simply processed instructions in memory, it would not serve any useful purpose. In order to be useful, the computer needs to provide a way to enable the user to indicate what calculations to perform, and to display the
28、 results of its calculations to interact with the computer.Interaction with a computer takes place through components called input/output devices. For example, a keyboard is an input device, because the computer can read from the keyboard to see when a key is pressed. From the computers perspective,
29、 the key press is information that is coming in. Conversely, a monitor is an output device, because the computer sends information out to the display as a result of its calculations. You may wonder how the computer can interact with these devices, when all it does is copy bytes from one place to ano
30、ther place. The answer is that all the input and output information can be represented as bytes. For example, each key on the keyboard has its own numeric value so the computer can identify the key and store the number in a memory location. Less obviously, the information displayed on your monitor r
31、ight now is just a series of bytes to the computer. Each dot (pixel) on the screen is represented by some bytes that indicate what color to display on the monitor at that pixel. In fact, everything that a computer displays or stores is a set of bytes, called a digital representation whether it is a
32、photo, a video, a song, or even a word processing document. If youve ever seen the movie The Matrix, youll recognize the image of green 0s and 1s cascading down a black screen. This image actually has some truth to it, since a computer sees all data as represented by numbers. The translation between what a computer sees and what we see on our monitors or as a printout is done by the input/output devices.The job of the computers input/output devices is to perform these conversions between th
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1