Archive for the ‘Programming’ Category
Why are a microprocessor’s instructions referred to as an instruction set? Because the microprocessor designer selects the instruction complement with great care; it must be simple to execute complicated operations as a sequence of simple events, each of which is represented by one instruction from a well-designed instruction set.
Assembler often frighten users who are new to programming. Yet taken in isolation, the operations involved in the execution of a single instruction are usually easy to follow. Moreover, you need not try to understand all the instructions at once. As you study each of the programs in these notes you will learn about the speciffic instructions involved.
Microprocessor datasheet lists the instruction mnemonics. This provides a survey of the processors capabilities, and will also be useful when you need a certain kind of operation but are either unsure of the specific mnemonics or not yet familiar with what instructions are available.
Microprocessor instructions are usually classified into few groups depending on what the instruction does. For example, the ARM microprocessor instruction set can be split into six broad classes of instruction.
• Data Movement
• Logical and Bit Manipulation
• Arithmetic
• Flow Control
• Memory Access
• System Control / Privileged
Microprocessor Arithmetic Operations
Much of the arithmetic in some microprocessor applications consists of multiple-word binary or decimal manipulations. The processor provides for decimal addition and subtraction, but does not provide for decimal multiplication or division, you must create these operations with sequences of instruction.
Most processors provide for both signed and unsigned binary arithmetic. Signed numbers are represented in two’s complement form. This means that the operations of addition and subtraction are the same whether the numbers are signed or unsigned.
Multiple-precision binary arithmetic requires simple repetitions of the basic instructions. The Carry flag transmits information between words. It is set when an addition results in a carry or a subtraction results in a borrow. Add with Carry and Subtract with Carry use this information from the previous arithmetic operation.
Decimal arithmetic is a standard enough task for microprocessors that most have special instructions for this purpose. These instructions may either perform decimal operations directly or correct the results of binary operations to the proper decimal form. Decimal arithmetic is essential in such applications as point-of-sale terminals, check processors, order entry systems, and banking terminals.
You can implement decimal multiplication and division as series of additions and subtractions, respectively. Extra memory must be reserved for results, since a multiplication produces a result twice as long as the operands. A division contracts the length of the result. Multiplications and divisions are time-consuming when done in software because of the repeated operations that are necessary.
Instruction set of any microprocessor or microcontroller is a precisely chosen list of instructions that can be used to write ANY program. It is up to the software engineer (or compiler) to select the right algorithm and order of instructions.
Find out useful recommendations in the sphere of Nanny Cam – make sure to go through the publication. The time has come when proper info is truly within your reach, use this opportunity.
The task of every compiler is to translate high-level language source code to machine code that will run on target processor. This may be achieved through assembly language file or by linking object files, the ultimate goal of every compiler is to generate code for the target processor. In principle this is a simple task. Every high level statement can be translated in a series of target instructions. However, without some optimizations this code would be very inefficient. Unoptimized code still works, but it is slower and the files are bigger.
The nature of high-level statements is to operate with variables. Loading and storing of variables can happen in any order. But transfers from and to memory are slower comparing to transfers between registers. And if some value is stored to memory location and immediately after it is needed again in a different calculation, then it doesn’t make sense to load it again since it was already present in some register. With proper register loading we can save a lot of redundant loads and stores. There are many optimization algorithms to make the code as efficient as possible. In fact, the compiler optimization is a science. There are many books written on this subject.
Most optimization algorithms are based on control and data flow analysis. There are many optimization approaches: to reduce jumps, to remove dead, redundant or common code, to remove redundant loads and stores, to use registers efficiently, to replace slow instructions with faster ones, to replace specific arithmetic calculations with short instructions, etc. Each optimization is based on some code or data properties. Some of the common optimizations include: constant folding, integer arithmetic optimizations, dead code elimination, branch elimination, code-block reordering, loop-invariant code motion, loop inversion, induction variable elimination, Instruction selection, instruction combining, register allocation, common sub-expression elimination, peephole optimizations, etc.
The basic rule of every optimization is that the original functionality of the program should not be changed. All optimization algorithms are based on the assumption that the program under analysis is the only one who changes memory locations. In reality interrupts or hardware ports can break this rule. Therefore proper actions must be taken to prevent optimizations on memory locations which might be modified outside the code we are trying to optimize. An additional programming technique that complicates optimizations is using pointers. But with proper analysis it is possible to apply safe optimizations on most parts of the code.
You can optimize the code for speed or for code size. In each case the program runs faster or occupies less memory. The later is extremely important in embedded programming where the memory of microcontrollers is limited. Compiler optimizations are an important part of every compiler. Unoptimized code is a waste of memory and time on any target system.
The author is a big Pascal programming language fan and has created a Free Pascal compiler for 8051 microcontrollers which uses Turbo Pascal syntax and generates optimized code. If you are interested in practical compiler construction you can examine the Turbo Pascal internals. This is Turbo Pascal compiler written in Delphi which can be used as an excellent book on compiler design.
Fetch important recommendations about the topic of internet marketing – read this webpage. The times have come when proper info is really at your fingertips, use this chance.
Turbo Pascal was probably the most widely used Pascal compiler of all times. Borland released it in early 1980s and at that time it was available on the CP/M and PC platform. It featured fast compiler, integrated development environment and a very affordable price. Its syntax, known also as Object Pascal, has become standard and the concept of units is still used in all modern implementations. Until recently Pascal programming language was taught in many schools. For many people it was the first step into computer programming. It is a language that is easy to write and easy to read so you need very few comments to understand what the program does.
Turbo Pascal in 1990s evolved into Delphi. This is a rapid application development tool for Windows. It still uses Object Pascal with many additional features. However, because of popularity in early years, there are many projects that were developed with Borland DOS compilers. If you would like to compile such project you would need the original compiler, most likely version 7.0 which was the last released DOS version. Unfortunately, this version is no longer available. Borland has some time ago released old versions of compilers free of charge: 1.0, 3.02 and 5.5. The last version 7.0 is not yet available.
If you would like to compile the old Pascal code you can either try to find the original compiler from one of the illegal sources or you can use the open-source Free Pascal in compatible mode. There is also a third option. You can use the TPC32 command line compiler which is available as part of the demo package of the TPC32 source files and can be downloaded for free. This is not some limited version, it is a fully functional compiler compatible with TPC.EXE command line compiler. It is called demo because the full version includes complete source files which are not available for free.
TPC32 is a successor of the TPC16, a compatible compiler written in Turbo Pascal 7. It is compatible with the original Borland compiler in all aspects. Compiles the same source files and generates binary compatible unit and executable files. TPC32 is still the same compiler, the sources were slightly modified to be compatible with Delphi 7 which doesn’t use the old segment-offset memory model. TPC32 still generates 16-bit x86 code. Source code of both compilers is available for purchase. You can use this source code to understand the internal data structures and algorithms of the famous Borland product or to make your own compiler. Both compilers are also available in demo versions which include fully functional compiled executable files. Because TPC16 is a DOS application it has some memory limitations. The TPC32 is a Win32 application and uses flat memory model with very few limitations. Both compilers can be used to compile the old projects created with the original Borland tools.
Pascal programming language is now rarely used in schools, but for some programmers it is still very popular and many old projects are still maintained. TPC32 compiler might be a solution for those who need a cheap and legal solution to compile the old Pascal sources.
Turbo Pascal can be used also to program embedded devices. For example, the Turbo51 – free Pascal compiler for 8051 microcontrollers uses Turbo Pascal syntax with some extensions to support specific 8051 features.
If you need a free compatible solution to compile the old Pascal projects you can download a demo version of the TPC32, Turbo Pascal compiler written in Delphi, which contains a fully functional command line compiler. You can also get the TPC32 source code. It can be used for your own project or as a great book on compiler design and implementation.
Grab vital knowledge about the topic of Empty Vacuum – study this web page. The time has come when concise info is truly within one click, use this possibility.