 |  |  | 4.3 Introduction to Assembly Programming |
4.3 Introduction to Assembly Programming
- Instructions
add
& sub
Read IA-32 Volume 2a [4]
and Read IA-32 Volume 2b [5]
- Instructions
idiv
& imul
Read IA-32 Volume 2 [4]
Please note the register restrictions.
- Carter Chapter 1, Introduction Section 1.3 on. pages 11-26 [1].
- Memory hierarchy
- Registers. Very fastest access times.
- Cache. Level I, II, III, .... Transparent to the user and the programmer except
for processing speed. This may impact the system programmer from time to time.
- DRAM, Core.
- Rotating storage both magnetic and optical. Magnetic tends to be faster than optical storage.
- Remote network storage. One form of off site backup.
- Removable media storage. Tape and optical drives.
- Program execution. What happens when you run a program?
Determination of an executable program.
Dynamic linked libraries
and shared object files.
Transfer of control. Change in execution mode. Interrupts.
- Machine language. What the hardware actually understands & how.
- Machine Architecture. Design tradeoffs. Chip size. Chip power. Pin count.
Chip I/O speed. Clock speed. Pipelining. Caching. Number and size of registers.
Adders, carry look ahead. Multipliers hardware / microcode / software.
Barrel shifters, floating point,
branch prediction, speculative execution, dual (multiple) cores,
SMP (Symmetric Multi-processing),
NUMA (Non-Uniform Memory Access), SIMD (Single Instruction, Multiple Data),
Vector processing, CISC (Complex instruction Set Computer), RISC (reduced
instruction Set Computer),
DSP (Digital Signal Processor) - Multiply/Accumulate instruction,
Memory address space,
I/O address space, Register address space. Instruction length. Orthogonal instruction set.
Harvard Architecture vs Von Neumann
Architecture
- IntelPentium Architecture. Historic demands. Clock speed vs. throughput.
- AMD
- 64 bit extensions
- Assembler
- nasm (dual platform)
- gas, gcc (ALL platforms)
- MASM, TASM (Microsoftonly)
- Assembler program format
- Overview of program structure
Comments, Data, Storage, Macros, & Code
- segment .data
initialized data
- segment .bss
uninitialized data
- segment .text
program
- Dr. Paul A. Carter's setup.
- Platform independent
- Multiple assemblers and compilers supported
- I/O library
- print_int. Print an integer
- print_string. Print a string.
- print_nl. Prints a new line character.
- Others see: Carterpage 16
- Debug macros see: Carterpage 17
- Files
- Linking and running - gort
curl -o linux-ex.zip http://drpaulcarter.com/pcasm/linux-ex.zip
unzip linux-ex.zip
make
(create initial objects and executables)
- edit (
pico lt1.asm
)
- assemble (
nasm -f elf lt1.asm
)
- link (
gcc -o lt1 driver.o lt1.o asm_io.o
)
- run (
./lt1
)
- Linking and running - Microsoft
- Install nasm or access system that has nasm [6] installed.
- Download Dr. Carter's programs
- Compile/assemble his examples (
make
)
- Run some of his examples.
- Write Program #2.
The last digit of your student services number
will be "N" in this lab.
The program needs to do the following:
- Print out your name and the date followed by a line with the
value of N by itself.
- Compute the following using 32 bit two's complement arithmetic.
DO NOT concern yourself with detecting overflow conditions.
Please note that the program uses no flow-of-control structures.
Use the following tables below to determine what your program needs to compute:
- Test your program. Do all of the arithmetic manually or with a high
level programming language. Compare thees results to what your program produces.
Turn this in. Testing is an important part of programming.
- Printout A, B, C, D, W, X,
Y, and Z with labels.
- Printout W+X+Y+Z with a label.
- Use the debug macro
dump_regs
at least once in your program.
- Turn in your test data (and program if there is one),
an error free listing of your program,
and the printed output of your program.
Valuesolspan="1" align="center">
N | A | B | C | D |
0 | 128 | 0x56 | 3 | 27 |
1 | 256 | 0x00 | 17 | 31 |
2 | 1024 | 0x12 | 23 | 47 |
3 | 2048 | 0x34 | 97 | 51 |
4 | 4096 | 0x77 | 22 | 71 |
5 | 8192 | 0xA7 | 153 | 3 |
6 | 64 | 0x80 | 9 | 7 |
7 | 32 | 0xB2 | 16 | 171 |
8 | 16 | 0x42 | 31 | 72 |
9 | 8 | 0x26 | 18 | 147
|
Equationsd colspan="1" align="center">
N
W | X | Y | Z |
0 | A+B | B+C | W/C | W*W |
1 | A+C | B+D | X/C | W*X |
2 | A+D | B+A | W/C | W*Y |
3 | B+C | A-D | X/C | W*W |
4 | B+D | C+A | W/C | X*X |
5 | C+D | D+A | X/C | X*Y |
6 | A+B | B-D | W/C | X*X |
7 | A+C | A-C | X/C | X*W |
8 | A+C | D-A | X/A | X*Y |
9 | A+C | B+D | X/A | X*C
|
Instructor: Louis Taber, louis.taber.at.pima at gmail dot com (520) 206-6850
My web site in Cleveland, OH
The Pima Community College web site
 |  |  | 4.3 Introduction to Assembly Programming |