・the assembler file
1 .file "hello.c"
2 .section .rodata
3 .LC0:
4 .string "Hello, World!\n"
5 .text
6 .p2align 2,,3
7 .globl main
8 .type main, @function
9 main:
10 pushl %ebp
11 movl %esp, %ebp
12 subl $8, %esp
13 andl $-16, %esp
14 movl $0, %eax
15 addl $15, %eax
16 addl $15, %eax
17 shrl $4, %eax
18 sall $4, %eax
19 subl %eax, %esp
20 subl $12, %esp
21 pushl $.LC0
22 call printf
23 addl $16, %esp
24 movl $0, %eax
25 leave
26 ret
27 .size main, .-main
28 .ident "GCC: (GNU) 3.4.6 [FreeBSD] 20060305"
a. "printf" is the instruction that calls the string output function.
it is a library
printf はソフト割り込みをかけていないため
b.
c. "call printf"
2.
1 .file "123.c"
2 .section .rodata
3 .LC0:
4 .string "123"
5 .text
6 .p2align 2,,3
7 .globl main
8 .type main, @function
9 main:
10 pushl %ebp
11 movl %esp, %ebp
12 subl $8, %esp
13 andl $-16, %esp
14 movl $0, %eax
15 addl $15, %eax
16 addl $15, %eax
17 shrl $4, %eax
18 sall $4, %eax
19 subl %eax, %esp
20 movl $.LC0, -4(%ebp)
21 subl $4, %esp
22 pushl $3
23 pushl -4(%ebp)
24 pushl $1
25 call write
26 addl $16, %esp
27 movl $0, %eax
28 leave
29 ret
30 .size main, .-main
31 .ident "GCC: (GNU) 3.4.6 [FreeBSD] 20060305"
a. "write". it is a system call.
b. 3個
3.
319個
http://d.hatena.ne.jp/toshi_hirasawa/20081105/1225885030
4.How long did it take you to complete this
for 1 hour.

As we discussed in class, you found the *call* instruction, but not the interrupt that traps into the kernel. What happens when you step into the write function? That should be a "wrapper" function that leads to the "int" instruction.
返信削除Score: 9/10