att

Making a system call in GAS and using variables in .data section and accessing them for a system call inside another sub-routine

霸气de小男生 提交于 2020-08-10 20:43:26
问题 Here is the code example that I have written using GAS syntax for 64 bit intel assembly. When the code is run the expectation is to print out the string: Inside the _print subroutine. #This example is a an example to call a subroutine .global _start .section .text _start: call _print _exit: #exit call mov $60, %rax xor %rdi, %rdi syscall _print: #set up the stack frame push %rbp mov %rsp, %rbp # write syscall's parameter set up mov std_out_fd, %rdi mov $message, %rsi movq message_size, %rdx

Why IDIV with -1 causes floating point exception?

折月煮酒 提交于 2020-08-09 04:42:18
问题 As far as I understood, idiv %ebx will divide edx:eax (concatenated into 64-bit value, in that order) with 32-bit ebx . However, when I try to divide 0x00000000:0xfffffffb (0 and -5) with 0xffffffff (-1), I get a floating-point exception. Can someone explain why? I'm quite puzzled why this is happening because I'm not dividing by 0 after all. Note that I know I need to sign extend edx:eax to achieve what I want, which is to calculate -5/-1 . However, even without sign extension the below

Understanding disassembled C code: dec %eax and movl $0x0,-0x8(%ebp)

我是研究僧i 提交于 2020-07-09 19:52:17
问题 I'm trying to understand the lines in a piece of disassembled code as shown below. I'd like to know the following: dec %eax : Why is the eax register being decremented? What is the initial value of the eax register? movl $0x0,-0x8(%ebp) : Why are we moving the value 0x0 onto the stack? Doesn't movl store a 32-bit value (4 bytes)? If so, why is the value being stored 8 bytes below the base pointer instead of 4 bytes? Here's the disassembled binary: Contents of section .text: 0000 554889e5

Understanding disassembled C code: dec %eax and movl $0x0,-0x8(%ebp)

核能气质少年 提交于 2020-07-09 19:51:03
问题 I'm trying to understand the lines in a piece of disassembled code as shown below. I'd like to know the following: dec %eax : Why is the eax register being decremented? What is the initial value of the eax register? movl $0x0,-0x8(%ebp) : Why are we moving the value 0x0 onto the stack? Doesn't movl store a 32-bit value (4 bytes)? If so, why is the value being stored 8 bytes below the base pointer instead of 4 bytes? Here's the disassembled binary: Contents of section .text: 0000 554889e5

google compute engine tool gcloud is exceptionally slow

寵の児 提交于 2020-06-10 08:05:29
问题 I tried downloading and using the gcloud bash tool to manage my accounts, however everything I do with the tool is exceptionally slow. It will take MINUTES to reply to a command that is typed. Is there perhaps a firewall I need to open up on my router or something else to get this to work fast like it's supposed to? For example, the "Installing..." lines in this video https://youtu.be/4y4-xn4Vi04?t=1m21s -- you'll notice they are all complete in the tutorial within a few seconds. This takes

google compute engine tool gcloud is exceptionally slow

北城以北 提交于 2020-06-10 08:05:19
问题 I tried downloading and using the gcloud bash tool to manage my accounts, however everything I do with the tool is exceptionally slow. It will take MINUTES to reply to a command that is typed. Is there perhaps a firewall I need to open up on my router or something else to get this to work fast like it's supposed to? For example, the "Installing..." lines in this video https://youtu.be/4y4-xn4Vi04?t=1m21s -- you'll notice they are all complete in the tutorial within a few seconds. This takes

How to interpret objdump disassembly output columns?

こ雲淡風輕ζ 提交于 2020-05-24 07:31:09
问题 I wrote a simple program in c which calls a function called while_loop with arguments 4,3,2. The function is just basically a while loop, I don't think it's really that relevant to my question since it's more of a generic question. I was told to run objdump -d, so I did. I have multiple questions so here it goes: I understand that in the leftmost column there are addresses and they increment according to the number of bytes in front. What I don't understand very well is the second column. Is

How to interpret objdump disassembly output columns?

妖精的绣舞 提交于 2020-05-24 07:30:10
问题 I wrote a simple program in c which calls a function called while_loop with arguments 4,3,2. The function is just basically a while loop, I don't think it's really that relevant to my question since it's more of a generic question. I was told to run objdump -d, so I did. I have multiple questions so here it goes: I understand that in the leftmost column there are addresses and they increment according to the number of bytes in front. What I don't understand very well is the second column. Is

Assembly executing a long jump with an offset with different syntax

為{幸葍}努か 提交于 2020-05-23 06:53:34
问题 I am writing a GDT for a Kernel and all is going well, I'm following this tutorial. http://www.osdever.net/bkerndev/Docs/gdt.htm When link the C code to the assembly code he uses this piece of code. ; This will set up our new segment registers. We need to do ; something special in order to set CS. We do what is called a ; far jump. A jump that includes a segment as well as an offset. ; This is declared in C as 'extern void gdt_flush();' global _gdt_flush ; Allows the C code to link to this

Regarding cmp / jg, jle, etc in AT&T syntax assembly

↘锁芯ラ 提交于 2020-05-09 06:36:05
问题 So every single resource online tells me that something like this: cmp %eax, %ebx jg < something > would jump to < something > if eax was greater than ebx. But I have another piece of code that seems to contradict this: cmp $0x2, %eax jg < something> as it jumps to < something > when eax has the value 3. Am I missing something, or does cmp a, b - jg execute if b > a and not a>b? And does this apply to other jump statements as well? 回答1: When we read something like cmp $0x2, %eax jg <