Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void op_dec_addr(void)
- {
- // tmp used: rax, rdi, rdx
- //
- // statically (must be preserved)
- // vm_data: rsi
- // vm_head: rbx
- // vm_tail: rcx
- // if (--(vm->vm_data) < vm->vm_head)
- asm ( "dec %rsi" );
- asm ( "cmp %rbx, %rsi" );
- asm ( "jl _exit2" );
- // pos = vm->vm_data - vm->vm_head;
- asm ( "mov %rsi, %rdx" );
- asm ( "sub %rbx, %rdx" );
- // data_size = (vm->vm_tail - vm->vm_head) + 0x20;
- asm ( "mov %rcx, %rdi" );
- asm ( "sub %rbx, %rdi" );
- asm ( "add $0x20, %rdi" );
- // save our structure
- asm ( "push %rsi" );
- asm ( "push %rbx" );
- asm ( "push %rcx" );
- asm ( "push %rdi" ); // save data_size
- // if (!(vm->vm_head = realloc(vm->vm_head, data_size)))
- asm ( "mov %rdi, %rsi" );
- asm ( "mov %rbx, %rdi" );
- asm ( "call realloc" ); // realloc(rdi, rsi)
- // restore our structure
- asm ( "pop %rdi" ); // restore data_size
- asm ( "pop %rcx" );
- asm ( "pop %rbx" );
- asm ( "pop %rsi" );
- asm ( "cmp $0, %rax" );
- asm ( "jne _continue_alloc2");
- // _abort(ABORT_ALLOC);
- asm ( "push $1" );
- asm ( "call _abort" );
- asm ( "_continue_alloc2:" );
- asm ( "mov %rax, %rbx" );
- // vm->vm_data = vm->vm_head + 0x20 + pos;
- asm ( "mov %rbx, %rsi" );
- asm ( "add $0x20, %rsi" );
- asm ( "add %rdx, %rsi" );
- // vm->vm_tail = vm->vm_head + data_size;
- asm ( "mov %rbx, %rcx" );
- asm ( "add %rdi, %rcx" );
- // memset(vm->vm_head, 0, 0x20);
- asm ( "_zero_memset2:" );
- asm ( "movb $0, (%rax)" );
- asm ( "inc %rax" );
- asm ( "cmp %rsi, %rax" );
- asm ( "jne _zero_memset2" );
- asm ( "_exit2:" );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement