Difference between revisions of "CSC231 Homework 7 2014"

From dftwiki3
Jump to: navigation, search
(Examples)
(Examples)
Line 20: Line 20:
 
* Submit your function in a program called '''Hw7_1.asm'''.
 
* Submit your function in a program called '''Hw7_1.asm'''.
 
<br />
 
<br />
==Examples==
+
==Example Test Program==
 
<br />
 
<br />
 
<source lang="asm">
 
<source lang="asm">
Line 38: Line 38:
 
           mov    eax, 0xffffffff
 
           mov    eax, 0xffffffff
 
           call    printInt        ; prints -1
 
           call    printInt        ; prints -1
           ...
+
            
 +
          mov    eax, 1
 +
          mov    ebx, 0
 +
          int    0x80   
 +
 
 
</source>
 
</source>
 
<br />
 
<br />
 +
 
=Problem #2=
 
=Problem #2=
 
<br />
 
<br />

Revision as of 10:38, 11 November 2014

--D. Thiebaut (talk) 10:33, 11 November 2014 (EST)


Page under construction


UnderConstruction.jpg


This assignment is due on 11/18/14, at 11:55 p.m.


Problem #1


  • & Use the 231Lib.asm library as inspiration and write a function called printInt that prints a 32-bit 2-s complement number on the screen.
  • Your function should work similarly to printDec, in that the number to print is passed through eax, and not through the stack!
  • Your function should not modify any of the registers, including eax.
  • Your function should be made global so that a test program can call it.
  • Submit your function in a program called Hw7_1.asm.


Example Test Program


          section .text

          extern  printInt
_start:
          mov     eax, 0
          call    printInt         ; prints 0
  
          mov     eax, 0xff
          call    printInt         ; prints 255

          mov     eax, -1
          call    printInt         ; prints -1

          mov     eax, 0xffffffff
          call    printInt         ; prints -1
          
          mov     eax, 1
          mov     ebx, 0
          int     0x80


Problem #2


  • Write a function called printInt16 that prints a 16-bit 2-s complement number on the screen.
  • Your function should work similarly to printInt, but the number it prints is the number passed in ax (not eax).
  • Your function should not modify any of the registers, including ax or the upper part of eax.
  • Your function should be made global so that a test program can call it.
  • Submit your function to Moodle in a program called Hw7_2.asm.


Example Test Program


          section .text

          extern  printInt16
_start:
          mov     ax, 0
          call    printInt16         ; prints 0
  
          mov     ax, 0xff
          call    printInt16         ; prints 255

          mov     eax, 0x0000ffff
          call    printInt16         ; prints -1

          mov     eax, 0xffff0001
          call    printInt16         ; prints 1
          
          mov     eax, 1
          mov     ebx, 0
          int     0x80