memory-address

Iterate over strings in assembly (NASM)

风流意气都作罢 提交于 2020-03-20 19:35:32
问题 I am trying to count the length of the string argv[1] in NASM assembly language. I think I'm on the right track. I have moved the address of argv[1] to register eax and now I want to move through it byte by byte and compare to the null string terminator. Everytime I run the code it segfaults on the null comparison. Am I not getting the memory indexing correct? *Disclaimer: This is a small part of a large homework assignment. segment .bss N: resd 1 ;counter for size of argv[1] segment .text

Iterate over strings in assembly (NASM)

拈花ヽ惹草 提交于 2020-03-20 19:32:46
问题 I am trying to count the length of the string argv[1] in NASM assembly language. I think I'm on the right track. I have moved the address of argv[1] to register eax and now I want to move through it byte by byte and compare to the null string terminator. Everytime I run the code it segfaults on the null comparison. Am I not getting the memory indexing correct? *Disclaimer: This is a small part of a large homework assignment. segment .bss N: resd 1 ;counter for size of argv[1] segment .text

How does this program know the exact location where this string is stored?

断了今生、忘了曾经 提交于 2020-02-03 04:28:07
问题 I have disassembled a C program with Radare2. Inside this program there are many calls to scanf like the following: 0x000011fe 488d4594 lea rax, [var_6ch] 0x00001202 4889c6 mov rsi, rax 0x00001205 488d3df35603. lea rdi, [0x000368ff] ; "%d" ; const char *format 0x0000120c b800000000 mov eax, 0 0x00001211 e86afeffff call sym.imp.__isoc99_scanf ; int scanf(const char *format) 0x00001216 8b4594 mov eax, dword [var_6ch] 0x00001219 83f801 cmp eax, 1 ; rsi ; "ELF\x02\x01\x01" 0x0000121c 740a je

X86_64 - assembly - Why displacement not 64 bits?

怎甘沉沦 提交于 2020-01-24 10:17:10
问题 I am reading the Intel x86_64 guide vol.1 to refresh how memory addressing works. Still, 3.7.5 Specifying an Offset The offset part of a memory address can be specified directly as a static value (called a displacement) or through an address computation made up of one or more of the following components: • Displacement — An 8-, 16-, or 32-bit value. I read in Agner Fog's assembly guide that 64-bit absolute addressing was possible when used with (r/e)ax register. So.. Is it possible, or not,

X86_64 - assembly - Why displacement not 64 bits?

主宰稳场 提交于 2020-01-24 10:17:05
问题 I am reading the Intel x86_64 guide vol.1 to refresh how memory addressing works. Still, 3.7.5 Specifying an Offset The offset part of a memory address can be specified directly as a static value (called a displacement) or through an address computation made up of one or more of the following components: • Displacement — An 8-, 16-, or 32-bit value. I read in Agner Fog's assembly guide that 64-bit absolute addressing was possible when used with (r/e)ax register. So.. Is it possible, or not,

Why is GDB filling the 0s of a memory address with 5s during a register info?

喜夏-厌秋 提交于 2020-01-24 10:12:11
问题 I am using GDB on a x64 CPU. As you can see, I am trying to access the value of the rip register and for some reason the address of the instruction the register is pointing to is displayed using 5s instead of 0s as it should be. Dump of assembler code for function main: 0x0000000000001139 <+0>: push rbp 0x000000000000113a <+1>: mov rbp,rsp 0x000000000000113d <+4>: sub rsp,0x10 0x0000000000001141 <+8>: mov DWORD PTR [rbp-0x4],0x0 0x0000000000001148 <+15>: mov DWORD PTR [rbp-0x4],0x0

How to print the memory address of a slice in Golang?

断了今生、忘了曾经 提交于 2020-01-22 10:59:47
问题 I have some experience in C and I am totally new to golang. func learnArraySlice() { intarr := [5]int{12, 34, 55, 66, 43} slice := intarr[:] fmt.Printf("the len is %d and cap is %d \n", len(slice), cap(slice)) fmt.Printf("address of slice 0x%x add of Arr 0x%x \n", &slice, &intarr) } Now in golang slice is a reference of array which contains the pointer to an array len of slice and cap of slice but this slice will also be allocated in memory and i want to print the address of that memory. But

How to print the memory address of a slice in Golang?

痴心易碎 提交于 2020-01-22 10:59:44
问题 I have some experience in C and I am totally new to golang. func learnArraySlice() { intarr := [5]int{12, 34, 55, 66, 43} slice := intarr[:] fmt.Printf("the len is %d and cap is %d \n", len(slice), cap(slice)) fmt.Printf("address of slice 0x%x add of Arr 0x%x \n", &slice, &intarr) } Now in golang slice is a reference of array which contains the pointer to an array len of slice and cap of slice but this slice will also be allocated in memory and i want to print the address of that memory. But

How to print the memory address of a slice in Golang?

…衆ロ難τιáo~ 提交于 2020-01-22 10:58:23
问题 I have some experience in C and I am totally new to golang. func learnArraySlice() { intarr := [5]int{12, 34, 55, 66, 43} slice := intarr[:] fmt.Printf("the len is %d and cap is %d \n", len(slice), cap(slice)) fmt.Printf("address of slice 0x%x add of Arr 0x%x \n", &slice, &intarr) } Now in golang slice is a reference of array which contains the pointer to an array len of slice and cap of slice but this slice will also be allocated in memory and i want to print the address of that memory. But

Bits in a memory address

六月ゝ 毕业季﹏ 提交于 2020-01-16 18:26:09
问题 While debugging on Windows XP 32-bit using the immunity debugger, I see the following on the stack: _Address_ -Value_ 00ff2254 ff090045 00ff2258 00000002 My understanding is that every address location contains 8 bits. Is this correct? 回答1: If I'm understanding your question correctly, the answer is yes, every individual memory location contains 8 bits. The debugger is showing you 4 bytes (32 bits) at a time, to make the display more compact (and because many data types take up 32 bits, so it