Discussion:
register pointer to memory
(too old to reply)
2***@nospicedham.mnit.ac.in
2020-01-14 08:47:38 UTC
Permalink
Hi,i am new in assembly coding. i want to do some memory address manipulation for my project
what i want is to save a memory address in a Register then done some manipulation on that address like changing the address and so on, then get the data from the newly updated address.
So far i am not able to do it.
i am using nasm.



mov ebx,000000h
add ebx,000230h
mov eax,[ebx]
push eax
push .fmt
call _printf
ret

.fmt db '%d',0x0d,0x0a,0

Thanks
JJ
2020-01-15 13:18:44 UTC
Permalink
Post by 2***@nospicedham.mnit.ac.in
Hi,i am new in assembly coding. i want to do some memory address manipulation for my project
what i want is to save a memory address in a Register then done some manipulation on that address like changing the address and so on, then get the data from the newly updated address.
So far i am not able to do it.
i am using nasm.
mov ebx,000000h
add ebx,000230h
mov eax,[ebx]
push eax
push .fmt
call _printf
ret
..fmt db '%d',0x0d,0x0a,0
Thanks
Your problem is not an assembly issue. But a problem understanding what kind
of value is expected by a function's argument.
2***@nospicedham.mnit.ac.in
2020-01-16 05:45:52 UTC
Permalink
Post by JJ
Post by 2***@nospicedham.mnit.ac.in
Hi,i am new in assembly coding. i want to do some memory address manipulation for my project
what i want is to save a memory address in a Register then done some manipulation on that address like changing the address and so on, then get the data from the newly updated address.
So far i am not able to do it.
i am using nasm.
mov ebx,000000h
add ebx,000230h
mov eax,[ebx]
push eax
push .fmt
call _printf
ret
..fmt db '%d',0x0d,0x0a,0
Thanks
Your problem is not an assembly issue. But a problem understanding what kind
of value is expected by a function's argument.
can you help me with that?

i can get the data from a particular memory location using section data, but i want to use registers, cause i want to change the address dynamically which i can'y do with section data

________________________________
lea si , [000000H]
lea di ,[test1]
movsb
movsb
push test1
call _printf
____________________________
section .data
test1: dd 00h

then i am getting output of 2 bytes.
but if i try to move the address to the register and then try to print it, its not printing anything, no error nothing just blank.section .data
____________________________________
mov ecx,000000h
mov eax, [ecx]
push eax
push .fmt
call _printf
ret

____________________________________
i just wanna know what is there that i am doing wrong.

In the end, I just want to get the data from a particular memory location using registers not using section data. is there any way?
Frank Kotler
2020-01-15 21:32:56 UTC
Permalink
Post by 2***@nospicedham.mnit.ac.in
Hi,i am new in assembly coding. i want to do some memory address manipulation for my project
what i want is to save a memory address in a Register then done some manipulation on that address like changing the address and so on, then get the data from the newly updated address.
So far i am not able to do it.
i am using nasm.
mov ebx,000000h
add ebx,000230h
mov eax,[ebx]
push eax
push .fmt
call _printf
ret
.fmt db '%d',0x0d,0x0a,0
Thanks
What platform? (Nasm will do a lot of things) Looks like Windows? What
happens? Exception? I don't think you have access to (virtual) memory at
that address. Try something in "section .data"...

{Sorry for the delay in your first post. This is a moderated NG and the
internet was down at my place. Should go faster from here on...)

Best,
Frank
2***@nospicedham.mnit.ac.in
2020-01-16 05:43:32 UTC
Permalink
Post by Frank Kotler
Post by 2***@nospicedham.mnit.ac.in
Hi,i am new in assembly coding. i want to do some memory address manipulation for my project
what i want is to save a memory address in a Register then done some manipulation on that address like changing the address and so on, then get the data from the newly updated address.
So far i am not able to do it.
i am using nasm.
mov ebx,000000h
add ebx,000230h
mov eax,[ebx]
push eax
push .fmt
call _printf
ret
.fmt db '%d',0x0d,0x0a,0
Thanks
What platform? (Nasm will do a lot of things) Looks like Windows? What
happens? Exception? I don't think you have access to (virtual) memory at
that address. Try something in "section .data"...
{Sorry for the delay in your first post. This is a moderated NG and the
internet was down at my place. Should go faster from here on...)
Best,
Frank
hi, thanks for the reply,
i don't think memory access is the issue
if i try to access memory data like this
________________________________
lea si , [000000H]
lea di ,[test1]
movsb
movsb
push test1
call _printf
____________________________
section .data
test1: dd 00h

then i am getting output of 2 bytes.
but if i try to move the address to the register and then try to print it, its not printing anything, no error nothing just blank.section .data
____________________________________
mov ecx,000000h
mov eax, [ecx]
push eax
push .fmt
call _printf
ret

____________________________________
i just wanna know what is there that i am doing wrong.

In the end i just want to get the data from a particular memory location using registers not using section data. is there any way?
Frank Kotler
2020-01-16 06:26:29 UTC
Permalink
On 01/16/2020 12:43 AM, ***@nospicedham.mnit.ac.in wrote:

...
Post by 2***@nospicedham.mnit.ac.in
i don't think memory access is the issue
if i try to access memory data like this
________________________________
lea si , [000000H]
lea di ,[test1]
movsb
movsb
push test1
This is the address of "test1". I doubt if that's what you want to print...
Post by 2***@nospicedham.mnit.ac.in
call _printf
____________________________
section .data
test1: dd 00h
then i am getting output of 2 bytes.
but if i try to move the address to the register and then try to print it, its not printing anything, no error nothing just blank.section .data
____________________________________
mov ecx,000000h
mov eax, [ecx]
push eax
push .fmt
call _printf
ret
____________________________________
i just wanna know what is there that i am doing wrong.
In the end i just want to get the data from a particular memory location using registers not using section data. is there any way?
What platform? Put another way, what command line are you giving Nasm?
Is this 16 bit code or 32 bit?

Best,
Frank
2***@nospicedham.mnit.ac.in
2020-01-16 07:47:59 UTC
Permalink
Post by Frank Kotler
...
Post by 2***@nospicedham.mnit.ac.in
i don't think memory access is the issue
if i try to access memory data like this
________________________________
lea si , [000000H]
lea di ,[test1]
movsb
movsb
push test1
This is the address of "test1". I doubt if that's what you want to print...
Post by 2***@nospicedham.mnit.ac.in
call _printf
____________________________
section .data
test1: dd 00h
then i am getting output of 2 bytes.
but if i try to move the address to the register and then try to print it, its not printing anything, no error nothing just blank.section .data
____________________________________
mov ecx,000000h
mov eax, [ecx]
push eax
push .fmt
call _printf
ret
____________________________________
i just wanna know what is there that i am doing wrong.
In the end i just want to get the data from a particular memory location using registers not using section data. is there any way?
What platform? Put another way, what command line are you giving Nasm?
Is this 16 bit code or 32 bit?
Best,
Frank
i am using windows,
nasm -f win32 int.asm
this is the command that i am using to create a object file
2***@nospicedham.mnit.ac.in
2020-01-16 07:51:53 UTC
Permalink
Post by Frank Kotler
...
Post by 2***@nospicedham.mnit.ac.in
i don't think memory access is the issue
if i try to access memory data like this
________________________________
lea si , [000000H]
lea di ,[test1]
movsb
movsb
push test1
This is the address of "test1". I doubt if that's what you want to print...
Post by 2***@nospicedham.mnit.ac.in
call _printf
so you are saying if i will push test1 in the stack and then call the printf function it willprint the address of the test1 not the data in the test1 ? if this is what you are saying than i have another example where i am using the same call but it is printing the data which is stored in test1
Post by Frank Kotler
Post by 2***@nospicedham.mnit.ac.in
____________________________
section .data
test1: dd 00h
then i am getting output of 2 bytes.
but if i try to move the address to the register and then try to print it, its not printing anything, no error nothing just blank.section .data
____________________________________
mov ecx,000000h
mov eax, [ecx]
push eax
push .fmt
call _printf
ret
____________________________________
i just wanna know what is there that i am doing wrong.
In the end i just want to get the data from a particular memory location using registers not using section data. is there any way?
What platform? Put another way, what command line are you giving Nasm?
Is this 16 bit code or 32 bit?
Best,
Frank
2***@nospicedham.mnit.ac.in
2020-01-16 08:01:09 UTC
Permalink
Post by Frank Kotler
Post by 2***@nospicedham.mnit.ac.in
i don't think memory access is the issue
if i try to access memory data like this
________________________________
lea si , [000000H]
lea di ,[test1]
movsb
movsb
push test1
This is the address of "test1". I doubt if that's what you want to print...
yso you are saying if i will push the variable test1 into the stack and then call the printf function it will print the address instead of the value?
Post by Frank Kotler
Post by 2***@nospicedham.mnit.ac.in
call _printf
____________________________
section .data
test1: dd 00h
then i am getting output of 2 bytes.
but if i try to move the address to the register and then try to print it, its not printing anything, no error nothing just blank.section .data
____________________________________
mov ecx,000000h
mov eax, [ecx]
push eax
push .fmt
call _printf
ret
____________________________________
i just wanna know what is there that i am doing wrong.
In the end i just want to get the data from a particular memory location using registers not using section data. is there any way?
What platform? Put another way, what command line are you giving Nasm?
Is this 16 bit code or 32 bit?
Best,
Frank
its windows 10
and this is the command that i am using
nasm -f win32 int.asm
Frank Kotler
2020-01-16 23:47:32 UTC
Permalink
Post by 2***@nospicedham.mnit.ac.in
Post by Frank Kotler
Post by 2***@nospicedham.mnit.ac.in
i don't think memory access is the issue
if i try to access memory data like this
________________________________
lea si , [000000H]
lea di ,[test1]
movsb
movsb
push test1
This is the address of "test1". I doubt if that's what you want to print...
yso you are saying if i will push the variable test1 into the stack and then call the printf function it will print the address instead of the value?
Right.
Post by 2***@nospicedham.mnit.ac.in
Post by Frank Kotler
Post by 2***@nospicedham.mnit.ac.in
call _printf
____________________________
section .data
test1: dd 00h
then i am getting output of 2 bytes.
but if i try to move the address to the register and then try to print it, its not printing anything, no error nothing just blank.section .data
Strange.
____________________________________
Post by 2***@nospicedham.mnit.ac.in
Post by Frank Kotler
Post by 2***@nospicedham.mnit.ac.in
mov ecx,000000h
mov eax, [ecx]
push eax
push .fmt
call _printf
ret
____________________________________
i just wanna know what is there that i am doing wrong.
In the end i just want to get the data from a particular memory location using registers not using section data. is there any way?
What platform? Put another way, what command line are you giving Nasm?
Is this 16 bit code or 32 bit?
Best,
Frank
its windows 10
and this is the command that i am using
nasm -f win32 int.asm
Okay. I haven't done Windows for a long time. Perhaps I should let
someone else help you. I would "expect" some of the things you're doing
to raise an exception. If it doesn't, it doesn't.

What you're doing...
mov ebx, 0
add ebx, ???
mov eax, [ebx]
; etc.
"should work" if there's memory at that address. Try 0x400000. As I
recall, that should be the start of the executable header. I may
remember that wrong... You should be pretty close to making it work.

Best,
Frank

Loading...