Syntactical error possibilities:
operands consistent with operation? (e.g., byte/long)
parameters allocated correctly? (order)
local variables allocated correctly?
storage space allocated on the stack for local vars?
loops have unconditional jumps back to beginning?
operands correct? (e.g., memory to memory)
local/parameter memory access consistency
jumping to correct labels? (e.g., begin while, not repeating init while)
pointer operations correct? (e.g., gets pointer address, not pointer value)
operands for add/sub/cmp correct? (e.g., addl %eax,$5)
void * dereference without cast?
Strategies:
comment code
read ahead and find out use of registers
no assembler-catchable errors
Exit code:
movl $1,%eax
movl $0,%ebx
int $0x80
Function entrance code:
//functionFoo(int *paramOne, char *paramTwo);
oldEbp = 0
retAddr = oldEbp + 4
paramOne = retAddr + 4
paramTwo = paramOne + 4
localOne = oldEbp - 4
localTwo = localOne - 4
pushl %ebp
movl %esp, %ebp
addl $localTwo,%esp
pushl %ebx
pushl %ecx
pushl %edx
... function body ...
popl %edx
popl %ecx
popl %ebx
subl $localTwo,%esp
popl %ebp
ret
Function call:
// functionFoo(int *paramOne, char *paramTwo);
pushl paramTwo(%ebp) // if paramTwo is char *
pushl paramOne(%ebp)
call functionFoo
addl $8,%esp
Moving data:
// if X_size defined statically
X_size: .fill 4, 1, 0xff // X_size is a memory address
...
movl X_size,%eax // eax is 0xffffffff (go to the address and get the value)
movl $X_size,%eax // eax is 0x804909c (treat the address as a literal)
// if X_size defined as a value
X_size = 4 // X_size is a value
...
movl X_size,%eax // eax is 0x8049090 (go to the value's addr and get data)
movl X_size+3,%eax
movl $X_size,%eax // eax is 4 (treat the value as a literal)
Incrementing pointers:
q = p + 1 // q is int32 *q; p is int32 *p
movl p(%ebp),%eax
addl $4,%eax //4 because sizeof(int32) = 4
Popping an element into memory:
popl Y_f1+X_f1(%eax)
Comparing byte:
cmpb $'\n',a+X_ch(%ebp)
$L1-2 evaluates L1-2 first
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(316)
-
▼
May
(41)
- Running Journal, Thursday, 2007-05-31
- Exploratorium
- IKEA Shopping
- Bone Marrow Donation
- Yosemite Vacation Products
- Degnan's Deli Menu
- Yosemite Vacation Journal
- Final Exam Notes
- Silver Sake Sushi
- vimdiff
- Sexidecimal
- GDB and Ignoring Break Points on the First Instruc...
- 2007 3rd Annual Sacramento Japanese Film Festival
- Running Journal, Friday, 2007-05-18
- SomaFM Radio Song
- Running Journal, Wednesday, 2007-05-16
- Running Journal, Tuesday, 2007-05-15
- Running Journal, Monday, 2007-05-14
- KYDS Radio Song
- Running Journal, Sunday, 2007-05-13
- American River Parkway Plants
- Running Journal, Friday, 2007-05-11
- Bugbear Cake!
- Running Journal, Wednesday, 2007-05-09
- My 32 Bit Integer
- KoL Bugbear Cake
- Running Journal, Tuesday, 2007-05-08
- Duff's Device
- Running Journal, Sunday, 2007-05-06
- Radio Song
- Cookie Monster
- Raining Milk
- Time for new shorts
- Running Journal, Friday, 2007-05-04
- Running Journal, Thursday, 2007-05-03
- Big Sur-vivor
- Radio Song
- ZipCar
- Smoothie Recipe
- Dawn's Nintendo DS Lite Wish List
- Big Sur Marathon Result
-
▼
May
(41)
No comments:
Post a Comment