CSC231 Homework 7 2015

From dftwiki3
Revision as of 12:58, 10 November 2015 by Thiebaut (talk | contribs) (Created page with "--~~~~ ---- <showafterdate after="20151111 12:00" before="20151231 00:00"> <bluebox> </bluebox> =Problem 1= <br /> <br /> Your assignment is to add a new function to '''231Li...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut (talk) 11:58, 10 November 2015 (EST)


<showafterdate after="20151111 12:00" before="20151231 00:00">

Problem 1



Your assignment is to add a new function to 231Lib2.asm called _printRegs.

  • Take your 231Lib.asm library and make a copy of it called 231Lib2.asm.
 cp 231Lib.asm 231Lib2.asm

  • Add a globalstatement at the top of the program (with the other similar statements):


global _printRegs


  • Go to the end of the file and add a new function called _printRegs


  • Your new function should display the contents of eax, ebx, ecx, edx, edi, and esi, in this order:
  • in hexadecimal (you should have a function for that)
  • as an unsigned number (_printDec will do that for you)
  • as a 2's complement signed number (you have to figure this part out).


  • Submit you 231Lib2.asm program to Moodle when done


Testing


  • To test your new function, create a new program that will be linked with your modified library, and will display all the registers.
  • Example test program:


;;;  extern functions that will be linked to this program
;;;  they are contained in 231Lib2.asm

extern  _printDec
extern  _printString
extern  _println
extern  _getInput
extern  _printRegs

;;; ------------------------------------------------------
;;; CODE SECTION
;;; ------------------------------------------------------        
                section .text
                global  _start
_start: 
                mov   eax, 0xFFFFFFFF
                mov   ebx, 0
                mov   ecx, 0x80000000
                mov   edx, 0x7FFFFFFF
                mov   esi,  2
                mov   edi, -2
 
                call    _printRegs

                mov   eax, 0xFFFFFFFF
                mov   ebx, 0
                mov   ecx, 0x80000000
                mov   edx, 0x7FFFFFFF
                mov   esi,  2
                mov   edi, -2
 
                call    _printRegs

</showafterdate>