att

x86 lea instruction

佐手、 提交于 2019-12-22 14:44:03
问题 I am trying to get a good grip on the LEA instruction in x86: leal (%edx, %edx, 4), %eax leal (%edx, %edx, 2), %eax Given these two lines, i know that: eax = edx + edx*4 and then eax = edx + edx*2 Two questions. First, if these instructions appear in sequence as in this example, the eax register is overwritten once the second line executes? And what exactly would be loaded into the register? Another address? Or is this doing arithmetic on the values that these registers point to? 回答1: if

How cmp assembly instruction sets flags (X86_64 GNU Linux)

若如初见. 提交于 2019-12-22 08:29:41
问题 Here is a simple C program: void main() { unsigned char number1 = 4; unsigned char number2 = 5; if (number1 < number2) { number1 = 0; } } So here we are comparing two numbers. In assembly it will be done using cmp. cmp works by subtracting one operand from other. Now how cmp is subtracting operands? Is it subtracting 1st operand from 2nd or vice versa? In any case, this should go like this: case # 1: 4 - 5 = (0000 0100 - 0000 0101) = (0000 0100 + 1111 1010 + 1) = (0000 0100 + 1111 1011) =

How is $example different from example(%rip)?

纵然是瞬间 提交于 2019-12-20 06:49:09
问题 I've spent 2 hours googling, but to no avail --- there are not many beginner-level guides for assembly, and the course I am taking right now dos not do a very good job at explaining some stuff. Anyway; I've been trying to work with SSE and tried comparing two double s using comisd instruction. I've spent a lot of time to understand how to hard-code a non-integer constant (let's call it example , it is declared as example: .long 3794832442 .long 1044740494 ); but after I've done that, I couldn

How to locate a variable correctly in AT&T assembly?

孤街醉人 提交于 2019-12-19 08:05:59
问题 I am practicing to write a bootstrap using assembly (in AT&T syntax, and gnu/gas). The small program is assembled and linked, then copied to the first sector of a virtual disk. BIOS will load it into 0000:7c00 , and here comes the problem. The call hello will be translated from call 0010 to call 7c10 during running. But the movw $message, %as doesn't get relocated. The ax is still 0026 , not 7c26 . The result is that I can't make the Hello World on the screen. Instead, some random data at

OE_ORDER_PUB.PROCESS_ORDER to Apply hold on a sales order

可紊 提交于 2019-12-19 03:38:48
PURPOSE: This post is to provide a sample script to Apply hold on a sales order using an API OE_ORDER_PUB.PROCESS_ORDER. TEST INSTANCE: R12.1.1 SCRIPT: DECLARE v_api_version_number NUMBER := 1; v_return_status VARCHAR2 (2000); v_msg_count NUMBER; v_msg_data VARCHAR2 (2000); -- IN Variables -- v_header_rec oe_order_pub.header_rec_type; v_line_tbl oe_order_pub.line_tbl_type; v_action_request_tbl oe_order_pub.request_tbl_type; v_line_adj_tbl oe_order_pub.line_adj_tbl_type; -- OUT Variables -- v_header_rec_out oe_order_pub.header_rec_type; v_header_val_rec_out oe_order_pub.header_val_rec_type; v

Understanding ATT Assembly (immediate)

五迷三道 提交于 2019-12-18 09:32:26
问题 lets say i have the following assembly lines movl $-1, %edi movl $1, %edx What exactly am I storing into %edi/%edx registers. Basically if I were to convert this code into a C program, would I be initalizing some variables to -1 and 1 because that's how I see it and that's where I think I'm getting confused. I understand that immediate = "some constant" but what does that mean? 回答1: There are four ways to load something into a register: Immediate value - in AT&T assembler, that's using a

Assembly - How to multiply/divide a constant by another constant in assembly?

放肆的年华 提交于 2019-12-17 22:04:12
问题 So, I have an assembly function, which is called in C. It compiles and gives me no warnings, but when I try to run it, it gives me a segmentation fault. I think it's because I can't move a constant into a register, but to use the mul/div command it requires a value to be in EAX register. How can I multiply or divide two constants in Assembly? Here's the code so far... .section .data .global n .equ A, 50 .equ B, 5 .section .text .global loop_function loop_function: # prologue pushl %ebp # save

x86 instruction meaning [duplicate]

风流意气都作罢 提交于 2019-12-17 20:56:21
问题 This question already has answers here : What is the meaning of MOV (%r11,%r12,1), %edx? (2 answers) How does “mov (%ebx,%eax,4),%eax” work? [duplicate] (1 answer) Closed 2 years ago . I'm running through some code right now on gdb and I have no clue what these two instructions actually do. If anyone could help me out, I'd really appreciate it. add -0x2c(%ebp, %ebx, 4), %eax cmp %eax, -0x28(%ebp, %ebx, 4) 回答1: x86 assembly is usually much easier to understand when you write it in Intel syntax

How to determine if the registers are loaded right to left or vice versa

百般思念 提交于 2019-12-17 17:12:58
问题 When reviewing gdb output and looking at the assembly calls, usually I can find a command using hard-coded values to determine whether the registers are being loaded right to left or vice versa. Usually something like the following: sub rsp, 16 or sub 16, rsp But other times, no values like above are visible. All I see are calls like the following : (gdb) disassemble Dump of assembler code for function main: 0x0000000100000f54 <main+4>: mov $rdi,%r15 0x0000000100000f59 <main+9>: mov $rsi,%r14

gas: too many memory reference

冷暖自知 提交于 2019-12-17 09:59:55
问题 When compiling the following instruction: movl 4(%ebp), 8(%ebp) I got: too many memory reference . What's wrong with it? 回答1: The number before the parenthesis is a byte offset (which causes a memory reference to occur), and you cannot have two of them with movl . You need to move the value temporarily to a register first. movl 4(%ebp), %ecx movl %ecx, 8(%ebp) 回答2: It is not a legal instruction. For most instructions that reference memory you must move it to/from a register. 回答3: movl doesn't