Difference between revisions of "CSC231 Homework 3 2010"

From dftwiki3
Jump to: navigation, search
(Problem #3)
(Problem #3)
 
Line 37: Line 37:
 
=Problem #3=
 
=Problem #3=
  
*  This time the information is stored in an array of double word, and you are going to take the least significant byte of each word and copy it into an array of bytes.
+
*  This time the information is stored in an array of double word, and you are going to take the least significant byte of each <font color="magenta">double</font>-word and copy it into an array of bytes.
  
 
    
 
    

Latest revision as of 21:09, 4 October 2010

--D. Thiebaut 12:59, 30 September 2010 (UTC)



This assignment is due on Wednesday Oct. 6, at 11:59 p.m. + 1 minute.


Problem #1

  • Assume that we have an array of bytes declared as follows:
     tableb     db      1, 10, 0xff, 5, 0x0a
and that we want to transfer it into an array of words defined as follows:
     tablew    dw      0, 0, 0, 0, 0
  • write the code necessary to transfer the information from tableb to tablew, so that each byte gets stored in a word, without the value changing. In other word, when 1 is copied from the first byte of tableb t the first word of tablew, the value in that word is 1, coded in 16 bits. Similarly, when 0xff is copied from the 3rd byte of tableb to the 3rd word of tablew, the value of that word is still 0xff, but coded in 16 bits.
  • We do not know loops yet, so do not use loops.
  • Since there are 5 pieces of information to copy, use different methods to copy each piece of information.
  • Store your program in a file called hw3a.asm and submit it as follows:
   submit hw3 hw3a.asm

Problem #2

  • Exact same question as Problem #1, but the second array, tabled, is now an array of double-words.
  • Store your program in a file called hw3b.asm and submit it as follows:
   submit hw3 hw3b.asm


Problem #3

  • This time the information is stored in an array of double word, and you are going to take the least significant byte of each double-word and copy it into an array of bytes.


    tabled      dd         1, 2, 255, 256, 0x12345678, 0x87654321

    tableb      db         0, 0, 0, 0, 0, 0
  • write a program which you will call hw3c.asm which contains the instructions necessary to store the least significant bytes of each word of tabled in the byte located at the same index in tableb.
  • In the header of your program, indicate what the final contents of the array tableb should be, in hexadecimal.
  • Submit your program as follows:
    submit hw3 hw3c.asm



Important note: it is not easy to print integers in assembly. One need to use a combination of C and assembly, which is complex (we'll look at it later). It's much easier right now to use a debugger (see Friday's lecture) to check what gets stored in memory.