`

gdb 调试nasm语法的汇编程序

 
阅读更多

首先看一个最基本的nasm语法汇编程序

 

hello.asm

section .text
global main

main:
mov eax, 4		; 4号调用
mov ebx, 1		; ebx送1表示stdout
mov ecx, msg		; 字符串的首地址送入ecx
mov edx, 14		; 字符串的长度送入edx
int 80h			; 输出字串
mov eax, 1		; 1号调用
int 80h			; 结束
msg:	db	"Hello World!", 0ah, 0dh

 

我 们想调用gdb进行调试,该怎么办呢?
请看下面的示例:
[root@localhost asm]# nasm -f elf64 hello.asm -g -F stabs
[root@localhost asm]# gcc -o hello hello.o -g
[root@localhost asm]# gdb hello            <========= 启动GDB

 

info break 查看断点

break (n)   设置断电

run 运行

 

ni 执行吓一跳指令

info r 查看寄存器

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics