- 论坛徽章:
- 0
|
GNU gdb Red Hat Linux (6.6-45.fc8rh)
源文件 sum1.asm
执行nasm -f elf -g -F stabs sum1.asm
执行ld -o sum1 sum1.o io.o
生成sum1可执行文件
[root@cryingpig sumAdd]# gdb sum1
GNU gdb Red Hat Linux (6.6-45.fc8rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) l
1 ;
2 ; Objective: To show parameter passing via registers.
3 ; Input: Two integers from the user.
4 ; Output: Outputs the sum of the input integers.
5
6 %include "io.mac"
7
8 .DATA
9 prompt_msg1 DB "input first number:",0
10 prompt_msg2 DB "input second number:",0
11 sum_msg DB "sum is ",0
12
13 .CODE
14 .STARTUP
15 PutStr prompt_msg1 ; request first number
16 GetInt CX ; CX = first number
17
18 PutStr prompt_msg2 ; request second number
19 GetInt DX ; DX= second number
20
21 call sum ; returns sum in AX
22 PutStr sum_msg ; display sum
23 PutInt AX
24 nwln
25 done:
26 .EXIT
27 sum:
28 mov AX,CX
29 add AX,DX
30 ret
(gdb) b 21
(gdb) b 18
Breakpoint 2 at 0x80493fc: file sum1.asm, line 18.
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x08049414 sum1.asm:21
2 breakpoint keep y 0x080493fc sum1.asm:18
(gdb) r
Starting program: /root/work/asm/sumAdd/sum1
input first number:123
inpu |
|