









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Bosworth; Class: Assembly Lang Programming 1; Subject: Computer Science; University: Columbus State University; Term: Unknown 1989;
Typology: Study notes
1 / 15
This page cannot be seen from the preview
Don't miss anything!










This depends on the decade in which you studied assembly language. 1940’s You cannot study assembly language. It does not exist yet. 1950’s You study assembly language because, other than raw binary machine language, it is the only way to program a computer. 1960’s & 1970’s You study assembly language in order to recode time–critical parts of your code generated by a compiler. In 1972, on a PDP–9, I could write assembly code that executed at least twice as fast as the equivalent compiled FORTRAN code. 1980’s You study assembly language in order to maintain the large base of legacy code, written in assembly language. Today Legacy code is still an issue, though a minor one. We study assembly language in order to understand the architecture of the computer and the nature of the software services provided. Focus on compilers and the run–time system.
These focus on the assumption that the student will soon be writing programs in assembly language. Today, this is rarely true. Here is a partial list of traditional goals for an assembly language course.
Didactically speaking: It is important for a student to study some assembly language, in order to understand the ISA (Instruction Set Architecture) of a sample stored–program computer. It is desirable to study an older and simpler ISA, one without the accretions seen in the Intel series of computers. Geographically Speaking: Assembly language is not much used these days. For the Columbus GA area the assembler of choice is IBM 370 mainframe assembler, as it is still in use by some of the larger companies in the Columbus area. Other Issues: This assembly language is an older design (late 1950’s and early 1960’s). As such it is fairly “primitive”, requiring that much be done explicitly. Having to do things explicitly is a learning opportunity.
The structure of an assembly language is dictated by the Instruction Set Architecture of the target computer. The ISA is defined as the view of that computer’s organization as it directly impacts the programmer. The standard model for all computers today, including the IBM Mainframe, is the stored program computer , also called a “von Neumann machine”. Programs and data are stored in an addressable memory. Computation is done in a separate unit, called the Central Processing Unit. Program instructions are fetched from memory into the CPU and executed. This process is called the “fetch/execute cycle”. The program achieves its effect by reading data values from memory, making computations on those data, and writing new values into the memory. All modern computers include Input/Output units to read user data into the computing process and allow output of results for human inspection.
The system memory (of which this computer has 512 MB) is used for transient storage of programs and data. This is accessed much like an array, with the memory address serving the function of an array index. The Input / Output system (I/O System) is used for the computer to save data and programs and for it to accept input data and communicate output data. Technically the hard drive is an I/O device. The Central Processing Unit (CPU) handles execution of the program. It has four main components:
For the moment, we shall focus on two components: the CPU and memory. The circuits used to implement the register set are faster and more costly than the circuits used to implement the main memory. Our computational model depends heavily on the use of CPU registers.
In higher–level programming languages, we declare variables by type and then use them. Assuming 32–bit integers, we might have: int x = 0 ; int y = 0 ; int z = 0 ; // More code here. The standard is “declare first and then use”. In a two–pass assembler, such as the IBM Mainframe assembly language, storage for variables is usually declared at the end of the program (more later). X DS F // Declare a full 32–bit word Y DS F // Each full word holds 4 bytes. Z DS F Notes: The storage area is not initialized to any particular value. Each of these storage locations should have an address that is a multiple of 4, to facilitate execution.
Consider the following fragment of Java code. int x ; float y, z ; // Define x and y z = x + y ; // Add integer to a float. This sort of type casting (integer to float) does not happen in assembly language. In assembly language, one must do something like the following.
Consider the following assembly language program, written for the Marie. It is given with its listing on left and its assembly on right. 000 Load X 000 1004 // Address 004 001 Add Y 001 3005 // Address 005 002 Store Z 002 2006 // Address 006 003 Halt 003 7000 X: Hex 0 004 0000 Y: Hex 0 005 0000 Z: Hex 0 006 0000 Were this code relocated to address 200, it would have to be changed. 200 1204 201 3205 202 2206 203 7000 // No address here. Two options: Use a linking loader that resolves addresses Use base register addressing. IBM assembler does this.
One of the bigger problems in compiler design is the allocation of registers to hold temporary results from computations. Study of assembly language will give a greater appreciation of the use of CPU general purpose registers and how good compilers allocate them. The one issue in the design of the compiler is the number of general purpose registers that can be allocated to hold intermediate results. The issue arises in the evaluation of expressions of moderate complexity, for which the compiler may have to write intermediate results back to memory. W = (X1 + X2)(Y1 + Y2)(Z1 + Z2 + Z3) The Marie (considered next) has only one register, the Accumulator. This considerably inhibits good compiler design.