4.8 Structures4 Schedule4.6 Subroutines4.7 Pointers and addressing

4.7 Pointers and addressing

 

4.7.1 Reading and Web Sites

  1. Read about operand addressing. Intel Vol # 1 p3-17
  2. Read about shell sorts.
  3. Read about pseudo random generators.
  4. Read about the XCHG instruction.
  5. Read about arrays in Carter Chapter 5.
  6. Read nasm section 3.3 page 33
  7. Read about JMP Intel Vol # 2A p3-384. Last sentence in the first paragraph under"Description". What does "or a memory location" mean?

4.7.2 Notes

4.7.3 Pseudo Random Number Generators

segment .data             ; initialized data 
lp   dd      1664525      ; large prime
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

4.7.4 Lab Assignment, Shell & Bubble Sorts

 

Write a program in assembly language that:

  1. Prints your name, class (CIS250) and the date.
  2. Print out "Simple Sort"
  3. Creates 4 lists of pseudo random numbers of different lengths. The lengths should be:
    1. 16
    2. 1024
    3. 65536
    4. 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 the array. Do this in segment .bss. Your code will be simpler and shorter if you only declare a single array.
  4. 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.
  5. 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:
  6. 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 dot lt dot Tucson dot AZ dot us (520) 206-6850
My new web Home site in Cleveland, OH
The Pima Community College web site

4.8 Structures4 Schedule4.6 Subroutines4.7 Pointers and addressing