att

A couple of questions about [base + index*scale + disp]

帅比萌擦擦* 提交于 2019-12-17 07:38:11
问题 The general form for memory addressing in Intel and AT&T Syntax is the following: [base + index*scale + disp] disp(base, index, scale) My questions are the following: Can base and index be any register? What values can scale take, is it 1, 2, 4 and 8 (with 1 being the default)? Are index and disp interchangeable (with the only difference being that index is a register while disp is an immediate value)? 回答1: This is described in Intel's manual: 3.7.5 Specifying an Offset The offset part of a

Printing an integer as a string with AT&T syntax, with Linux system calls instead of printf

邮差的信 提交于 2019-12-17 02:51:26
问题 I have written a Assembly program to display the factorial of a number following AT & t syntax.But it's not working.here is my code .text .globl _start _start: movq $5,%rcx movq $5,%rax Repeat: #function to calculate factorial decq %rcx cmp $0,%rcx je print imul %rcx,%rax cmp $1,%rcx jne Repeat # Now result of factorial stored in rax print: xorq %rsi, %rsi # function to print integer result digit by digit by pushing in #stack loop: movq $0, %rdx movq $10, %rbx divq %rbx addq $48, %rdx pushq

CSS语法

一曲冷凌霜 提交于 2019-12-16 23:00:05
CSS 语法 CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明。 ''' selector { property: value; property: value; ... property: value } ''' 例如: h1 {color:red; font-size:14px;} css的四种引入方式 1.行内式 行内式是在标记的style属性中设定CSS样式。这种方式没有体现出CSS的优势,不推荐使用。 <p style="background-color: rebeccapurple">hello yuan</p> 2.嵌入式 嵌入式是将CSS样式集中写在网页的<head></head>标签对的<style></style>标签对中。格式如下: <head> <meta charset="UTF-8"> <title>Title</title> <style> p{ background-color: #2b99ff; } </style> </head> 3 链接式 将一个.css文件引入到HTML文件中 <link href="mystyle.css" rel="stylesheet" type="text/css"/> 4.导入式 将一个独立的.css文件引入HTML文件中,导入式使用CSS规则引入外部CSS文件,<style>标记也是写在<head

Using .org directive with data in .data section: In connection with ld

穿精又带淫゛_ 提交于 2019-12-13 14:33:00
问题 In my efforts to understand how to use the GNU binutils to build a simple boot loader using gas I have come across the question, how do you tell the linker where to put your data, in a file that uses .org to advance the location counter while keeping the file size at 512 bytes. I can't seem to find a way to do this. The assembly program that tries to do this is: # Author: Matthew Hoggan # Date Created: Tuesday, Mar 6, 2012 .code16 # Tell assembler to work in 16 bit mode .section .data msg: #

What does lea 0xY(%esp), %esi do?

爱⌒轻易说出口 提交于 2019-12-13 08:55:55
问题 I dont understand what this code will do lea 0x13(%esp), %esi %esp is a stack pointer, %esi is index register. Is 0x13 offset? 回答1: I'm used to the Intel syntax, so I believe this is what's happening: lea esi, [esp+13h] Say esp is 0x18000 - the result of this operation will be 0x18013, since you're not actually accessing any memory with lea . Again, I only have experience with the Intel syntax, so my answer may be incorrect. Hopefully this has helped you! 来源: https://stackoverflow.com

飞控IMU姿态估计流程

♀尐吖头ヾ 提交于 2019-12-13 07:52:46
飞控中使用加速度计,陀螺仪,磁罗盘进行姿态估计算法流程。 step1: 获取陀螺仪,加速度计,磁罗盘的原始数值。 step2: 陀螺仪,加速度计减去固定的偏移后得到校准数值,磁罗盘通过偏移和缩放后得到校准数值。(都是在载体坐标系下的测量值)。 step3: 首先根据上次的飞控姿态四元数计算出载体坐标系在世界坐标系中的旋转矩阵。 公式:从四元数 q ( w , x , y , z ) q(w,x,y,z) q ( w , x , y , z ) 到旋转矩阵 [ 1 − 2 y 2 − 2 z 2 2 x y + 2 w z 2 x z − 2 w y 2 x y − 2 w z 1 − 2 x 2 − 2 z 2 2 y z + 2 w x 2 x z + 2 w y 2 y z − 2 w x 1 − 2 x 2 − 2 y 2 ] \begin{bmatrix} {1 - 2{y^2} - 2{z^2}} & {2xy + 2wz} & {2xz - 2wy} \\ {2xy - 2wz} & {1 - 2{x^2} - 2{z^2}} & {2yz + 2wx} \\ {2xz + 2wy} & {2yz - 2wx} & {1 - 2{x^2} - 2{y^2}} \\ \end{bmatrix} ⎣ ⎡ ​ 1 − 2 y 2 − 2 z 2 2 x y − 2 w z 2

read and print number of command-line arguments in Linux assembly

霸气de小男生 提交于 2019-12-13 05:53:59
问题 I'm writing an assembly program with AT&T syntax (GAS compiling) on an Intel processor and on Ubuntu 14. I'm trying to read the number of parameters passed by the user at the moment of program launch. For instance if user open his terminal and types ./programname x y z I'd like that the nParameters variable assumes value 4 (because programname, x, y and z are parameter). This is what I've done so far but I keep getting a segementation fault error. .code32 .section .data nParameters: .byte 0

What does cmpq compare?

若如初见. 提交于 2019-12-13 03:18:36
问题 mystery has this function signature: int mystery(char *, int); This is the mystery function assembly code: mystery: movl $0, %eax ;set eax to 0 leaq (%rdi, %rsi), %rcx ; rcx = rdi + rsi loop: cmpq %rdi, %rcx jle endl decq %rcx cmpb $0x65, (%rcx) jne loop incl %eax jmp loop endl: ret What does this line cmpq %rdi, %rcx compare? The address or the character value? If it is comparing the address stored inside the registers, what's the point though? If one address is greater than the other, so?

Cycle Through and Print argv[] in x64 ASM

▼魔方 西西 提交于 2019-12-12 13:00:56
问题 I have been working on essentially a while loop to go through all CLI arguments. While working on solution to only print 1 element I noticed a few things; this was the thought process that led me to here. I noticed that if I did lea 16(%rsp), %someRegisterToWrite , I was able to get/print argv[1]. Next I tried lea 24(%rsp), %someRTW and this gave me access to argv[2]. I kept going up to see if it would continue to work and it did. My thought was to keep adding 8 to %someRTW and increment a

x64: How to do a relative jmp *%rax?

旧时模样 提交于 2019-12-12 06:48:46
问题 I want to encode a 64 bit relative jump to the address stored in %rax in x64 assembly. AFAIK, there is no opcode for this, so I calculate the corresponding absolute address for the relative address manually and then I do an absolute jump to the absolute address: # destination address, relative to end of jmp instruction, is stored in %rax 00007ffff7ff6020: 0x0000488d1505000000 lea 0x5(%rip),%rdx # load %rip+5 (rip + size of add and jmpq) into %rdx 00007ffff7ff6027: 0x0000000000004801d0 add