Difference between revisions of "CSC231 Homwork 2 Solution 2010"
(Created page with '--~~~~ ---- __TOC__ =Mystery Program= <code><pre> [231a@beowulf Submitted]$ cat hw2_mystery.lst 1 ;;; program_name.asm 2 …') |
(→Mystery Program) |
||
Line 7: | Line 7: | ||
<code><pre> | <code><pre> | ||
− | + | ||
1 ;;; program_name.asm | 1 ;;; program_name.asm | ||
2 ;;; your name | 2 ;;; your name | ||
Line 122: | Line 122: | ||
113 000000CC BB00000000 mov ebx,0 | 113 000000CC BB00000000 mov ebx,0 | ||
114 000000D1 CD80 int 0x80 ; final system call | 114 000000D1 CD80 int 0x80 ; final system call | ||
− | 115 | + | 115 |
− | |||
− | |||
</pre></code> | </pre></code> | ||
Revision as of 16:35, 6 October 2010
--D. Thiebaut 21:35, 6 October 2010 (UTC)
Contents
Mystery Program
1 ;;; program_name.asm
2 ;;; your name
3 ;;;
4 ;;; a description of the program
5 ;;;
6 ;;; to assemble and run:
7 ;;;
8 ;;; nasm -f elf -F stabs program.asm
9 ;;; ld -melf_i386 -o program program.o
10 ;;; ./program
11 ;;; -------------------------------------------------------------------
12
13 ;%include files here...
14
15 EXIT equ 1
16 WRITE equ 4
17 STDOUT equ 1
18
19 ;; ------------------------------------------------------------
20 ;; data areas
21 ;; ------------------------------------------------------------
22
23 section .data
24 00000000 206D616B657320 m2 db " makes "
25 M2LEN equ $-m2
26 00000007 706572666563742E2E- m3 db "perfect..."
27 00000010 2E
28 M3LEN equ $-m3
29 00000011 7072616374696365 m1 db "practice"
30 M1LEN equ $-m1
31 00000019 627574206E6F626F64- m4 db "but nobody's "
32 00000022 79277320
33 M4LEN equ $-m4
34 00000026 736F2077687920 m5 db "so why "
35 M5LEN equ $-m5
36 0000002D 3F0A0A m6 db "?",0x0a,0x0a
37 M6LEN equ $-m6
38
39
40 ;; ------------------------------------------------------------
41 ;; code area
42 ;; ------------------------------------------------------------
43
44 section .text
45 global _start
46
47 _start:
48 00000000 B804000000 mov eax, WRITE
49 00000005 BB01000000 mov ebx, STDOUT
50 0000000A B9[11000000] mov ecx, m1 ; practice
51 0000000F BA08000000 mov edx, M1LEN
52 00000014 CD80 int 0x80
53
54 00000016 B8FFFFFFFF mov eax, -1
55 0000001B B804000000 mov eax, WRITE
56 00000020 BB01000000 mov ebx, STDOUT
57 00000025 B9[07000000] mov ecx, m3
58 0000002A B9[00000000] mov ecx, m2
59 0000002F BA07000000 mov edx, M2LEN
60 00000034 CD80 int 0x80
61
62 00000036 BA[11000000] mov edx, m1
63 0000003B B801000000 mov eax, STDOUT
64 00000040 B804000000 mov eax, WRITE
65 00000045 BB01000000 mov ebx, STDOUT
66 0000004A B9[07000000] mov ecx, m3
67 0000004F BA0A000000 mov edx, M3LEN
68 00000054 CD80 int 0x80
69
70 00000056 B804000000 mov eax, WRITE
71 0000005B BB01000000 mov ebx, STDOUT
72 00000060 B9[19000000] mov ecx, m4
73 00000065 BA0D000000 mov edx, M4LEN
74 0000006A CD80 int 0x80
75
76 0000006C B804000000 mov eax, WRITE
77 00000071 BB01000000 mov ebx, STDOUT
78 00000076 B9[06000000] mov ecx, m3-1
79 0000007B BA0A000000 mov edx, M3LEN
80 00000080 41 inc ecx
81 00000081 CD80 int 0x80
82
83 00000083 B804000000 mov eax, WRITE
84 00000088 BB01000000 mov ebx, STDOUT
85 0000008D B9[24000000] mov ecx, m5-2
86 00000092 41 inc ecx
87 00000093 BA07000000 mov edx, M5LEN
88 00000098 41 inc ecx
89 00000099 CD80 int 0x80
90
91 0000009B B804000000 mov eax, WRITE
92 000000A0 BB01000000 mov ebx, STDOUT
93 000000A5 B9[11000000] mov ecx, m1
94 000000AA BA08000000 mov edx, M1LEN
95 000000AF CD80 int 0x80
96
97 000000B1 B804000000 mov eax, WRITE
98 000000B6 BB01000000 mov ebx, STDOUT
99 000000BB B9[2D000000] mov ecx, m6
100 000000C0 BA03000000 mov edx, M6LEN
101 000000C5 CD80 int 0x80
102
103
104
105 ;; (add your code here!!!!)
106
107
108
109
110 ;; exit()
111
112 000000C7 B801000000 mov eax,EXIT
113 000000CC BB00000000 mov ebx,0
114 000000D1 CD80 int 0x80 ; final system call
115