assembly

Why is data stored in memory reversed?

故事扮演 提交于 2021-02-08 09:59:03
问题 This is the source code I have: section .data msg: db "pppaaa" len: equ $ section .text global main main: mov edx,len mov ecx,msg mov ebx,1 mov eax,4 int 0x80 And when I debug this code I will see: (gdb) info register ecx ecx 0x804a010 134520848 (gdb) x 0x804a010 0x804a010 <msg>: 0x61707070 (gdb) x 0x804a014 0x804a014: 0x00006161 "70" here represents the character 'p' and "61" the character 'a' obviously. What I am confused about is, why is the data in location 0x804a010 is 0x61707070 (appp)

Why is data stored in memory reversed?

倾然丶 夕夏残阳落幕 提交于 2021-02-08 09:59:01
问题 This is the source code I have: section .data msg: db "pppaaa" len: equ $ section .text global main main: mov edx,len mov ecx,msg mov ebx,1 mov eax,4 int 0x80 And when I debug this code I will see: (gdb) info register ecx ecx 0x804a010 134520848 (gdb) x 0x804a010 0x804a010 <msg>: 0x61707070 (gdb) x 0x804a014 0x804a014: 0x00006161 "70" here represents the character 'p' and "61" the character 'a' obviously. What I am confused about is, why is the data in location 0x804a010 is 0x61707070 (appp)

Why is data stored in memory reversed?

风流意气都作罢 提交于 2021-02-08 09:58:51
问题 This is the source code I have: section .data msg: db "pppaaa" len: equ $ section .text global main main: mov edx,len mov ecx,msg mov ebx,1 mov eax,4 int 0x80 And when I debug this code I will see: (gdb) info register ecx ecx 0x804a010 134520848 (gdb) x 0x804a010 0x804a010 <msg>: 0x61707070 (gdb) x 0x804a014 0x804a014: 0x00006161 "70" here represents the character 'p' and "61" the character 'a' obviously. What I am confused about is, why is the data in location 0x804a010 is 0x61707070 (appp)

Little to big endian using multiplication and division - MIPS assembly

吃可爱长大的小学妹 提交于 2021-02-08 09:50:30
问题 I have a school assignment that requires me to convert a word from little endian to big endian in three different ways. One of them is by using multiplication and division. I know that shifting to the left multiplies the number by 2 but i still cant figure out how to utilise that. Here is me doing it using rotate. Can someone help me step on this and do it with division and multiplication? .data .text .globl main main: li $t0,0x11223344 #number to be converted in t0 rol $t1,$t0,8 li $t2

OFFSET Operator in Assembly language for x86 Processors

ⅰ亾dé卋堺 提交于 2021-02-08 09:18:24
问题 I am rather confused by the concept OFFSET Operator. According to Kip R. Irvine's book Assembly Language for x86 Processors, he defines the Offset Operator as the operator that returns the distance of a variable from the beginning of its enclosing segment. He also says the Offset Operator returns the offset of a data label and that represents the distance (in bytes) of the label from the beginning of the data segment. What is the offset? What does he mean by the distance of the label from the

ARM Assembly - Change input file to only include capital letters and spaces, write to output

北战南征 提交于 2021-02-08 08:21:21
问题 I'm taking an x86 class right now, and we have an ARM assembly assignment, which is a copy of an x86 asssignment we did. Basically it reads in from a file, changes lowercase letters to uppercase, and keeps spaces. So it only writes capital letters (change the lowercase letters if they are lowercase), and copy the spaces, while getting rid of numbers and characters. We are using only hex characters 00h-7F (even though the lowest usable character we have is 0x20). I tried to convert my code

ARM Assembly - Change input file to only include capital letters and spaces, write to output

∥☆過路亽.° 提交于 2021-02-08 08:19:44
问题 I'm taking an x86 class right now, and we have an ARM assembly assignment, which is a copy of an x86 asssignment we did. Basically it reads in from a file, changes lowercase letters to uppercase, and keeps spaces. So it only writes capital letters (change the lowercase letters if they are lowercase), and copy the spaces, while getting rid of numbers and characters. We are using only hex characters 00h-7F (even though the lowest usable character we have is 0x20). I tried to convert my code

Estimating Cycles Per Instruction

早过忘川 提交于 2021-02-08 08:15:11
问题 I have disassembled a small C++ program compiled with MSVC v140 and am trying to estimate the cycles per instruction in order to better understand how code design impacts performance. I've been following Mike Acton's CppCon 2014 talk on "Data-Oriented Design and C++", specifically the portion I've linked to. In it, he points out these lines: movss 8(%rbx), %xmm1 movss 12(%rbx), %xmm0 He then claims that these 2 x 32-bit reads are probably on the same cache line therefore cost roughly ~200

Estimating Cycles Per Instruction

混江龙づ霸主 提交于 2021-02-08 08:14:12
问题 I have disassembled a small C++ program compiled with MSVC v140 and am trying to estimate the cycles per instruction in order to better understand how code design impacts performance. I've been following Mike Acton's CppCon 2014 talk on "Data-Oriented Design and C++", specifically the portion I've linked to. In it, he points out these lines: movss 8(%rbx), %xmm1 movss 12(%rbx), %xmm0 He then claims that these 2 x 32-bit reads are probably on the same cache line therefore cost roughly ~200

Generating square wave in AVR Assembly without PWM

北慕城南 提交于 2021-02-08 08:06:11
问题 I'm using an ATmega328. The thing is that I want to generate a square wave of a given frequency and of a given amplitude. PWM can't be used because I was given a board that has already been soldered, so the wave has to be put at the output of an R2R resistor ladder that is connected to the B port of the processor. So, basically, the idea is that I have to put the pins of port B in 0 and VOLUME (VOLUME is a number that goes from 1 to 255) periodically, with a given frequency and a duty cycle