Difference between revisions of "CSC231 Homework 8 Fall 2012"
(→Problem 1) |
(→Requirements) |
||
Line 57: | Line 57: | ||
mov eax, 0x12345678 | mov eax, 0x12345678 | ||
+ | mov ebx, 0x11112222 | ||
+ | mov ecx, 0x5555AAAA | ||
+ | mov edx, 0x66669999 | ||
+ | mov edi, 0x9abcdef | ||
+ | mov esi, 0x11111111 | ||
+ | |||
+ | call dumpRegs | ||
+ | |||
==Submission == | ==Submission == | ||
Revision as of 12:51, 31 October 2012
--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.
- You need to make sure the dumpRegs function work correctly. For this you will initialize the registers as followed before calling the function:
mov eax, 0x12345678 mov ebx, 0x11112222 mov ecx, 0x5555AAAA mov edx, 0x66669999 mov edi, 0x9abcdef mov esi, 0x11111111 call dumpRegs
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 are not correct. For example
Problem #2