CSC231 HexDump Exercise Solution
--D. Thiebaut 12:46, 14 September 2012 (EDT)
Solution of Hexdump exercise
1 ;;; mickeyMouse.asm
2 ;;; D. Thiebaut
3 ;;;
4 ;;; Display "Hello Mickey" on the screen, followed by 3 line-feeds.
5 ;;;
6 ;;; To assemble, link, and run:
7 ;;; nasm -f elf -F stabs mickeyMouse.asm
8 ;;; ld -melf_i386 -o mickeyMouse mickeyMouse.o
9 ;;; ./mickeyMouse
10 ;;;
11
12 section .data
13 00000000 48656C6C6F204D6963- Hello db "Hello Mickey"
14 00000009 6B6579
15 0000000C 204D6F75736521 Mouse db " Mouse!"
16 00000013 0A0A0A lflflf db 10, 10, 10
17
18
19 section .text
20 global _start
21 _start:
22
23 ;;; print "Hello Mickey"
24 00000000 B804000000 mov eax, 4 ; write
25 00000005 BB01000000 mov ebx, 1 ; stdout
26 0000000A B9[00000000] mov ecx, Hello ; address of message to print
27 0000000F BA0C000000 mov edx, Mouse-Hello ; # of chars to print
28 00000014 CD80 int 0x80
29
30 ;;; print 3 line-feed chars
31
32 00000016 B804000000 mov eax, 4 ; write
33 0000001B BB01000000 mov ebx, 1 ; stdout
34 00000020 B9[13000000] mov ecx, lflflf ; address of message to print
35 00000025 BA03000000 mov edx, 3 ; # of chars to print
36 0000002A CD80 int 0x80
37 ;;; exit
38 0000002C BB00000000 mov ebx, 0
39 00000031 B801000000 mov eax, 1
40 00000036 CD80 int 0x80
41
42