Well, for my first post I guess I'll ask if anyone's tried cgdb.  Since I started with gdb, then found cgdb, and I have been using it anytime I compile nasm with -g. Though yesterday I found asmbug and have been tinkering around with that, but I still like cgdb.

Also, I'd like to add, although I've been learning Nasm and assembly in general for only a few days (if not counting the weeks that I haven't been doing so), I just don't have many questions to ask.  After finding the linuxasmtools yesterday and looking through the code, and as well as reading the first few pages of the pcasm book, example bootloaders, and compiled c programs with gdb and cgdb from when I first started I've figured out almost everything I need to get going.  The only thing I need is to remember it, but eh a few trials and examples here and there, I'm sure I'll remember it all eventually.

Oh, also I'd like your opinions on a bit of code I've used for when testing functions. I'm just curious as to how good/bad it is. It's a few macros for use with functions that need several local variables.


;
;
; Macro list to make programming with nasm easier.
;
; Pascal like routines for
;
; begin Prepares a function for use.
; var x init x number of local variables.
; end
;
; Others...
;
; local(x) Imagine the local variables organized in an array.
; arg(x) Same as local, but for arguments passed to the function.
;
; WARNING WARNING WARNING WARNING
;
; BE SURE TO REMEMBER TO POP OFF ALL PARAMETERS SO THEY DON'T EXIST ANY MORE.
;

%macro begin 0
push ebp
mov ebp, esp
%endmacro

%macro var 1
sub esp, %1*4 ; Create space for n number of variables. (four bytes per register).
%endmacro

%macro end 0
mov esp, ebp
pop ebp
ret
%endmacro

%define local(a) ebp-(a*4) ; mov eax, will place the first local variable into eax.
; add , eax ; Same as add , eax ; ebp-(1*4)=(ebp-(1*4)) + eax

%define arg(a) ebp+4+(a*4) ; mov eax, will place the first argument passed to the function in eax.


??...Thanks
Posted on 2010-01-25 11:44:54 by Mol_Bolom
Hadn't heard about cgdb, but it could turn out fairly useful if I ever need to do some linux debugging... looks a lot nicer than vanilla GDB, which imho is horrible :)

The macros are perhaps a bit simple - but every journey has it's beginnings. You might want to check out the NASMX project.
Posted on 2010-01-25 12:24:04 by f0dder
I have not used cgdb but I will be looking into it. I mostly use a mix of strace and gdb for all of my debugging under linux and tbh I'm about sick of gdb lol. cgdb looks interesting but I'm not getting my hopes up just yet, I thought Insight looked cool as well but it turned out to be fairly useless.

As for your macros file, no problem with the macros, they are short and simple. Very nicely done. I also would suggest, like f0dder, that you check out the NASMX project, more importantly the NASMX.INC file. It's pretty much the same idea, only a bit more complex and has 64-bit support. You should be able to understand the macros in that file fairly well, the VAR() and ARG() macros are implemented in much the same way as your local() and arg() macro are with the exception they support names instead of just numbers.

Also, sapero is working on a nice extention to nasm in the form of %proc/%local/%endproc support which I'm sure will be a big hit when he finishes. From what I've seen they work a lot like the MASM versions do, so you might want to keep your eyes open for that.

Regards,
Bryant Keller
Posted on 2010-01-25 14:32:59 by Synfire
I wonder how many remote GDB debugger replacements that are available, by the way - it's possible to have your debuggee running on a linux machine, and doing the actual debugging from the comfort of Windows. The only debugger than GDB that I know has remote GDB support is very recent versions of the IDA disassembler... and it looks extremely powerful, check out the Hex Blog. Probably the coolest thing is that recent VMWare and QEMU versions have GDB stubs... you do realize what that means, yes? :)
Posted on 2010-01-25 14:43:46 by f0dder

I have not used cgdb but I will be looking into it. I mostly use a mix of strace and gdb for all of my debugging under linux and tbh I'm about sick of gdb lol. cgdb looks interesting but I'm not getting my hopes up just yet, I thought Insight looked cool as well but it turned out to be fairly useless.


Heh, I felt the same way about gdb for the first few days of learning and using it, then searching I found cgdb.  Actually started using asmbug a bit more today and quite frankly I think I like it better, kind of reminds of of the old Borland TD back when Win 3.1 was around, though I might be wrong, it's been 10 years since I've last used it.

As for your macros file, no problem with the macros, they are short and simple. Very nicely done. I also would suggest, like f0dder, that you check out the NASMX project, more importantly the NASMX.INC file. It's pretty much the same idea, only a bit more complex and has 64-bit support. You should be able to understand the macros in that file fairly well, the VAR() and ARG() macros are implemented in much the same way as your local() and arg() macro are with the exception they support names instead of just numbers.

Also, sapero is working on a nice extention to nasm in the form of %proc/%local/%endproc support which I'm sure will be a big hit when he finishes. From what I've seen they work a lot like the MASM versions do, so you might want to keep your eyes open for that.

Regards,
Bryant Keller


I do have nasmx in a directory, had it for quite a while, and looks like I'll have to go through it again. Didn't notice the VAR() and ARG() macros.

I am, also, wondering if I could install a 64 bit system on this computer. It's not a great computer (2.0ghz, 1gb), but I could just go with a console install of Slackware and that would suffice. Just to give me a system for trying 64 bit code on. Perhaps wouldn't even have to bother with that and install it with qemu, running it from the console probably wouldn't eat up that much memory. Eh, I've still got a lot to learn, but I'm figuring it out...

Thanks f0dder and Synfire


Posted on 2010-01-25 19:11:18 by Mol_Bolom