| | | 4.6 Pointers and addressing |
4.6 Pointers and addressing
- Read about operand addressing. Intel Vol # 1 p3-17
- Read about shell sorts.
- Read about pseudo random generators.
- Read about the
XCHG
instruction.
- Read about arrays in Carter Chapter 5.
- Read nasm section 3.3 page 33
- Read about
JMP
Intel Vol # 2A p3-384. Last
sentence in the first paragraph under"Description". What does
"or a memory location" mean?
- Addressing modes
- Immediate -- Constants. nasm section 3.4
- Register
- a memory location
- an I/O port
- Indirect addressing
Intel Vol #1 page 3-30.
- Displacement
- Base
- Base + Displacement
- (Index * Scale) + Displacement
- Base + Index + Displacement
- Base + (Index * Scale) + Displacement
- Base + (Index * Scale) + Displacement
- multi-way branch
jmp [indirect]
-- case
segment .bss ; uninitialized data
pseudo_internal resd 1 ; pseudo random gen seed
segment .text
pseudo_init: ; init
push eax ; place zero on pseudo_internal
mov eax,0
mov [pseudo_internal],eax
pop eax
ret
pseudo: ; generate new "random" number
push edx
mov eax,[pseudo_internal] ; get old seed
mul dword[lp] ; (a-1 mod 4) == 0, a is prime
add eax,1013904223
xchg ah,al
mov [pseudo_internal],eax ; save for next number
and eax,0x7FFFFFFF ; return only positive numbers
pop edx
ret
Write a program in assembly language that:
- Prints your name, class (CIS250) and the date.
- Print out "Simple Sort"
- Creates 4 lists of pseudo random numbers of different lengths.
The lengths should be:
- 16
- 1024
- 65536
- 262144
(Try 1048576 double word for the shell sort if your system is fast enough.)
32 bit words. Use the provided pseudo random number generator to fill the
arrays. Initialize the pseudo random number generator with a zero
prior to filling each array. Do this in segment .bss
.
- Sort each array with a bubble sort. Count the number of exchanges done.
At the end of each sort, print the first and last eight (8) elements of each array,
and the number of exchanges performed.
- Redo step 3. The repeat step 4 with a shell sort instead of a bubble sort.
Search the web for "shell sort". Or try this link:
- Extra credit is given for coding a loop for the various array sizes.
Turn in a printed error free listing and the output of your program.
Include a copy of any testing that you did to verify the program was correct.
Instructor: Louis Taber, ltaber(at)uml.lt.Tucson.AZ.us (520) 206-6850
My new web Home site in Cleveland, OH
The Pima Community College web site
| | | 4.6 Pointers and addressing |