Contact polprog at Esper/DALnet/Libera for info
Name Last modified Size Description
Parent Directory -
x87-coprocessor.c 2018-02-28 19:15 795
simple.cpp 2018-02-28 19:15 659
readme.txt 2019-10-04 00:55 1.6K
loop.cpp 2018-03-06 22:21 522
labels.cpp 2018-02-28 19:15 700
Theese are some snippets from my adventures in learning x86_64 assembly.
Files:
simple.cpp
	The simplest way of doing inline assembly. Compares a number from stdin
	only the comparison part is implemented in assembly
labels.coo
	Similar to above, but uses named tokens instead of cryptic %0, %1 etc
x87-coprocessor.c
	Calculates the square root of 2 and 141 using the FPU. Once using float in C and once using a double
loop.cpp
	Another simple snippet
Compilation:
	g++ <filename.cpp>
	or
	gcc <filename.c>
Further messing around
	You can (and should) run gdb and take a look "inside"
	You may want to read /blog/ddd/ (which covers some gdb commands as well)
	Start with
	gdb a.out
	you will see a prompt:
	(gdb)
	Some useful commands in this case
	"run <args" and "cont" - run and continue. args optional
	"layout asm" (short: "lay asm") - displays assembly window
	"layout reg" ("lay reg") - displays registers
	"where" - when you forget where you are (prints current program position)
	"disas" - disassemble current function
	"info registers", "info registers $eax", "p $eax" - print register values
	"set $eax=123" - set register value.
	"stepi" "nexti" - step 1 instruction. "nexti" skips function calls
	"display [variable/register]" - keep track of value (examine, 'x' command takes 
	same args)
	ex:
	  display/x $eax - keep printing eax value
	  display/20xb $esp - display 20 hexadecimal (x) bytes (b) starting from address in $esp
	  display $esp	
	  display/2i $eip - display two instructions starting from the next one
	etc.
	breakpoints: "break *main+12" if you want to set a breakpoint at main+12 for example.
	You can specify an address as well.
	have fun