SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 285 | Next

Shon Harris, Allen Harper, Chris Eagle, and Jonathan Ness

"Gray Hat Hacking, Second Edition"


??? .text The .text directive is used to hold the program??™s commands.
For example, the following assembly program prints ???Hello, haxor!??? to the screen:
section .data ;section declaration
msg db "Hello, haxor!",0xa ;our string with a carriage return
len equ $ - msg ;length of our string, $ means here
section .text ;mandatory section declaration
;export the entry point to the ELF linker or
global _start ;loaders conventionally recognize
; _start as their entry point
_start:
;now, write our string to stdout
;notice how arguments are loaded in reverse
mov edx,len ;third argument (message length)
mov ecx,msg ;second argument (pointer to message to write)
mov ebx,1 ;load first argument (file handle (stdout))
Gray Hat Hacking: The Ethical Hacker??™s Handbook
136
Register Registers hold the data to be manipulated. No
memory interaction. Both registers must be the
same size.
mov ebx, edx
add al, ch
Immediate Source operand is a numerical value. Decimal is
assumed; use h for hex.
mov eax, 1234h
mov dx, 301
Direct First operand is the address of memory to
manipulate. It??™s marked with brackets.
mov bh, 100
mov[4321h], bh
Register Indirect The first operand is a register in brackets that
holds the address to be manipulated.


Pages:
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297