CSC231 Homework 8 Fall 2012

From dftwiki3
Revision as of 12:57, 31 October 2012 by Thiebaut (talk | contribs) (Grading)
Jump to: navigation, search

--D. Thiebaut 13:14, 31 October 2012 (EDT)


Problem 1

  • Write an assembly file called hw8a.asm that will contain a series of functions (you decide how many) that help print the contents of all the registers on the screen. The main function will be called dumpRegs and when you call it, all the major registers ( eax, ebx, ecx, edx, edi and esi) will be displayed in hex on the screen, inside a nice box. Here is an example of how your function could get used in a simple hello program:


		section	.data
Hello		db	"Hello there!", 10, 10, 10
HelloLen	equ	$-Hello

		section	.text
		global	_start
_start:	

;;; print message
		mov	eax, 4		; write
		mov	ebx, 1		; stdout

                call   dumpRegs

		mov	ecx, Hello	; address of message to print
		mov	edx, HelloLen	; # of chars to print
		int 	0x80

;;; exit
		mov	ebx, 0
		mov	eax, 1
		int	0x80


The output of the program will be (something like) this:

+------------------+
| eax = 0000 00 04 |
| ebx = 0000 00 01 |
| ecx = F503 21 11 |
| edx = 0000 12 FC |
| edi = FFFF EEC3  |
| esi = 1223 5557  |
+------------------+
Hello there!


Requirements

  • You cannot use the driver.c program. Use int 0x80 to print information.
  • You should have one function for printing the line that is used for the top and bottom of the box
  • You should have one function that prints a hexadecimal digit.
  • You should have one function that prints a byte in hex. This function will call the function that prints a digit twice.
  • You should have one function that prints a 16-bit word in hex. This function will call the function that prints a byte twice.
  • The dumpReg function does all the work necessary, calling various functions, to print the box and the 8 registers and their contents.
  • The dumpReg function does not modify any of the main registers, nor does it change the ESP or EBP registers. It may use them for its own purpose, but it will restore them to their original values.
  • You need to make sure the dumpRegs function works correctly. For this you will initialize the registers as follows before calling the function, and you will call the function twice.
mov    eax, 0x12345678
mov    ebx, 0x11112222
mov    ecx, 0x5555AAAA
mov    edx, 0x66669999
mov    edi, 0x89abcdef
mov    esi, 0x11111111

call    dumpRegs
call    dumpRegs
  • The output should be exactly as follows:
+------------------+
| eax = 1234 56 78 |
| ebx = 1111 22 22 |
| ecx = 5555 AA AA |
| edx = 6666 99 99 |
| edi = 89AB CDEF  |
| esi = 1111 1111  | 
+------------------+
+------------------+
| eax = 1234 56 78 |
| ebx = 1111 22 22 |
| ecx = 5555 AA AA |
| edx = 6666 99 99 |
| edi = 89AB CDEF  |
| esi = 1111 1111  | 
+------------------+

Submission

To show that your set of functions work well Submit your program as follows:

  rsubmit hw8 hw8a.asm

Grading

Points will be taken off significantly if the contents of the registers printed on the screen are not correct.

Problem #2