att

What's the purpose of looping “xorl %edx,%eax; shrl $1,%edx”?

你离开我真会死。 提交于 2019-12-01 21:41:02
问题 I have the following x86 assembly code: movl 8(%ebp), %edx //get an argument from the caller movl $0, %eax testl %edx, %edx je .L1 .L2: // what's the purpose of this loop body? xorl %edx, %eax shrl $1, %edx jne .L2 .L1: andl $1, %eax The corresponding C code that the textbook gives as follows int f1(unsigned x) { int y = 0; while(x != 0) { __________; } return __________; } The book asks readers to fill the blank and answer the question of "What does it do?" I can't combine the loop body in

Defining “variables” in assembly language

可紊 提交于 2019-12-01 20:56:58
I underdstand that this is extremely stupid quiestion, but I can't figure an answer for some time How do I correctly declare and define "variables" in GAS AT&T assembly language? For example, I want buffer for 5 bytes, two 1-byte variables (initially with 0 value), 2-byte variable with 0 and 2-byte variable with 10. This code doesn't work correctly, at least debugger says (on the first line of the program, after these declarations, just nop instruction) that b and c are big numbers instead of zeros. .bss .lcomm r, 5 .data a: .byte 0 b: .byte 0 c: .word 0 d: .word 10 Here's what you see in your

Assembly (,%eax,4)

吃可爱长大的小学妹 提交于 2019-12-01 19:49:03
If one of my command lines says: jmp *0x804a180(,%eax,4) what does that mean? I ask specifically because there is no value before the first comma and I'm not sure exactly what the * before the address means. This instruction jumps to the location whose value is located at the address calculated as %eax * 4 + 0x804a180 . The * is used in AT&T syntax to indicate indirect jumps and calls. It basically means "jump to the location pointed to by this, instead of the value of this". It is useful to differentiate the following instructions: jmp myAddress # Jumps to the location myAddress jmp

How to load address of function or label into register in GNU Assembler

前提是你 提交于 2019-12-01 19:01:06
I am trying to load the address of 'main' into a register (R10) in the GNU Assembler. I am unable to. Here I what I have and the error message I receive. main: lea main, %r10 I also tried the following syntax (this time using mov) main: movq $main, %r10 With both of the above I get the following error: /usr/bin/ld: /tmp/ccxZ8pWr.o: relocation R_X86_64_32S against symbol `main' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status Compiling with -fPIC does not resolve the

What's the purpose of looping “xorl %edx,%eax; shrl $1,%edx”?

好久不见. 提交于 2019-12-01 18:23:26
I have the following x86 assembly code: movl 8(%ebp), %edx //get an argument from the caller movl $0, %eax testl %edx, %edx je .L1 .L2: // what's the purpose of this loop body? xorl %edx, %eax shrl $1, %edx jne .L2 .L1: andl $1, %eax The corresponding C code that the textbook gives as follows int f1(unsigned x) { int y = 0; while(x != 0) { __________; } return __________; } The book asks readers to fill the blank and answer the question of "What does it do?" I can't combine the loop body in one C expression. I can tell what the loop body does, but I have no idea about its purpose. The textbook

assembly cltq and movslq difference

ⅰ亾dé卋堺 提交于 2019-12-01 16:45:50
Chapter 3 of Computer Systems A Programmer's Perspective (2nd Edition) mentions that cltq is equivalent to movslq %eax, %rax . Why did they create a new instruction ( cltq ) instead of just using movslq %eax,%rax ? Isn't that redundant? TL;DR : use cltq when possible, because it's one byte shorter than the exactly-equivalent movslq %eax, %rax . That's a very minor advantage (so don't sacrifice anything else to make this happen) but choose eax if you're going to want to sign-extend it a lot. This is mostly relevant for compiler-writers (compiling signed-integer loop counters indexing arrays);

pytorch关系抽取实验

陌路散爱 提交于 2019-12-01 16:13:13
接前面笔记: 关系抽取总结 中最后说的,在关系抽取基于Distant Supervision的NYT+Freebase的数据集有两个版本,目前大部分文章都是在这两份数据集上做的。通过纵向实验发现,同一个模型在不同版本数据集上的表现有不少差异,这篇笔记是基于自己使用Pytorch复现的PCNN(Zeng 2015)与PCNN+ATT(Lin 2016)的实验结果来简单对比。 代码地址: pytorch-relation-extraction ,关于实现的细节,调参,踩过的一些坑等,会记录在readme中,这里不再赘述。 个人属于入门级别, 复现代码可能有问题, 结果供参考. 数据集 首先描述一下这两份数据集: 27类关系,Zeng2015 发布的数据集,做了一些过滤,如删除了两个实体之间距离大于40个词的句子,以及去掉了实例少的关系,相对较小,以SMALL表示:详细数据如下所示: 训练数据集: 实体对: 65726; 句子数: 112941; 关系数: 27 测试数据集: 实体对: 93574; 句子数: 152416 53类关系,Lin2016 发布的数据集,没有做过滤,相对较大,训练数据大概是小数据的4倍,以LARGE表示,详细如下: 训练数据集: 实体对: 281270; 句子数: 522611; 关系数: 53 测试数据集: 实体对: 96678; 句子数: 172448;

What's the difference between the x86-64 AT&T instructions movq and movabsq?

点点圈 提交于 2019-12-01 16:11:24
After reading this stack overflow answer , and this document , I still don't understand the difference between movq and movabsq . My current understanding is that in movabsq , the first operand is a 64-bit immediate operand whereas movq sign-extends a 32-bit immediate operand. From the 2nd document referenced above: Moving immediate data to a 64-bit register can be done either with the movq instruction, which will sign extend a 32-bit immediate value, or with the movabsq instruction, when a full 64-bit immediate is required. In the first reference, Peter states: Interesting experiment: movq

What's the difference between the x86-64 AT&T instructions movq and movabsq?

孤者浪人 提交于 2019-12-01 16:05:26
问题 After reading this stack overflow answer, and this document, I still don't understand the difference between movq and movabsq . My current understanding is that in movabsq , the first operand is a 64-bit immediate operand whereas movq sign-extends a 32-bit immediate operand. From the 2nd document referenced above: Moving immediate data to a 64-bit register can be done either with the movq instruction, which will sign extend a 32-bit immediate value, or with the movabsq instruction, when a

assembly cltq and movslq difference

十年热恋 提交于 2019-12-01 15:31:10
问题 Chapter 3 of Computer Systems A Programmer's Perspective (2nd Edition) mentions that cltq is equivalent to movslq %eax, %rax . Why did they create a new instruction ( cltq ) instead of just using movslq %eax,%rax ? Isn't that redundant? 回答1: TL;DR : use cltq when possible, because it's one byte shorter than the exactly-equivalent movslq %eax, %rax . That's a very minor advantage (so don't sacrifice anything else to make this happen) but choose eax if you're going to want to sign-extend it a