Why does STR only work for addresses between 0x40000000 and 0x40003FFF?Why won't this change the values of some of the elements in array1 in memory?str and ldr instruction does not use same addressCan not find string defined in Data Area at the correct addressLDR and STR not working?How do I label a memory location in ARM assembly?KEIL MCB1700 Evaluation Board BrickedARM Assembly: write number located on stackKeil uVision simulator - why does the same variable have two addresses? Why is it initialized as 0 when it's not?LPC2148 assembly code. Trying to read data from read-write memory but Label showing blank dataLabel exported from assembly file is not accessible in cGetting PC (R15) set to point to my code after placing it in RAM at the desired address with Keil, on an embedded ARM device
Print the phrase "And she said, 'But that's his.'" using only the alphabet
Why not make one big cpu core?
How effective would a full set of plate armor be against wild animals found in temperate regions (bears, snakes, wolves)?
I sent an angry e-mail to my interviewers about a conflict at my home institution. Could this affect my application?
Fastest way from 10 to 1 with everyone in between
Why is gun control associated with the socially liberal Democratic party?
Jam with honey & without pectin has a saucy consistency always
Is it possible to install Firefox on Ubuntu with no desktop enviroment?
Can you open the door or die? v2
Why are backslashes included in this shell script?
How to represent jealousy in a cute way?
Can a 40amp breaker be used safely and without issue with a 40amp device on 6AWG wire?
Manager wants to hire me; HR does not. How to proceed?
Why did the AvroCar fail to fly above 3 feet?
Can artificial satellite positions affect tides?
What is the theme of analysis?
Why does this Apple //e drops into system monitor when booting?
My parents claim they cannot pay for my college education; what are my options?
Harley Davidson clattering noise from engine, backfire and failure to start
Is it possible to have battery technology that can't be duplicated?
Commencez à vous connecter -- I don't understand the phrasing of this
How can this shape perfectly cover a cube?
Does WiFi affect the quality of images downloaded from the internet?
Background for black and white chart
Why does STR only work for addresses between 0x40000000 and 0x40003FFF?
Why won't this change the values of some of the elements in array1 in memory?str and ldr instruction does not use same addressCan not find string defined in Data Area at the correct addressLDR and STR not working?How do I label a memory location in ARM assembly?KEIL MCB1700 Evaluation Board BrickedARM Assembly: write number located on stackKeil uVision simulator - why does the same variable have two addresses? Why is it initialized as 0 when it's not?LPC2148 assembly code. Trying to read data from read-write memory but Label showing blank dataLabel exported from assembly file is not accessible in cGetting PC (R15) set to point to my code after placing it in RAM at the desired address with Keil, on an embedded ARM device
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Code:
dest EQU 0x40000000
AREA name, CODE, READONLY
ENTRY
MOV r0, #2
LDR r1, =dest
STR r0, [r1]
stop B stop
END
This code writes the value of 2 to memory location 0x40000000.
When I change this to 0x20000000, 2 fails to get written there. Same thing with 0x3FFFFFFF. When I set the memory location to 0x40003FFF, 2 gets printed onto that location, but when I change the address to 0x40004000, 2 fails to get printed there. Same thing for any address locations higher, like 0x50000000. So according to these outputs, it seems like STR only writes values onto a finite range of memory between 0x40000000 and 0x40003FFF.
Does anyone know why this is the case? Or is there something wrong with my code? I am using Keil uVision5, NXP LPC2140.
assembly arm keil arm7
|
show 5 more comments
Code:
dest EQU 0x40000000
AREA name, CODE, READONLY
ENTRY
MOV r0, #2
LDR r1, =dest
STR r0, [r1]
stop B stop
END
This code writes the value of 2 to memory location 0x40000000.
When I change this to 0x20000000, 2 fails to get written there. Same thing with 0x3FFFFFFF. When I set the memory location to 0x40003FFF, 2 gets printed onto that location, but when I change the address to 0x40004000, 2 fails to get printed there. Same thing for any address locations higher, like 0x50000000. So according to these outputs, it seems like STR only writes values onto a finite range of memory between 0x40000000 and 0x40003FFF.
Does anyone know why this is the case? Or is there something wrong with my code? I am using Keil uVision5, NXP LPC2140.
assembly arm keil arm7
You read the documentation yes? what part did you not understand?
– old_timer
Mar 25 at 1:03
@old_timer Documentation? You mean Keil's reference guide for STR? Yes. You mean what happens in memory during my debugging stage? Yes.
– John Park
Mar 25 at 1:10
2
@phuclv Hmm, I think you've thrown a red herring here. The OP changes the 'dest EQU', so the R1 contains the address he wants to write into and there is no need for immediates or shifts or anything of that sort. (See keil.com/support/man/docs/armasm/armasm_dom1361289875065.htm) for LDR pseudo-instruction. I believe that write attempts fail when he attempts to write into read-only/non-existent memory or something along these lines. It's hard to comment on this without knowing the environment (I asked about this in his previous question).
– tum_
Mar 25 at 10:19
2
The "NXP LPC2140" seems to have only 16kB of SRAM (Static Random-Access-Memory) which can hold values and can be modified. Seems like it is mapped into address space at 0x40000000..0x40003FFF ... you should be able to find this "mapping" info in data sheets for your platform, or in examples coming with it. (16kiB of memory means 16384 bytes... that's probably less than this web page has, so you have to be careful when designing code for it, to use the memory effectively).
– Ped7g
Mar 25 at 11:07
1
@JohnPark the first thing you do when you start to work with a microcontroller is download the datasheet. These days and in this case and depending on vendor you also get a programmers reference manual which can vary by name, users manual, reference manual. And from those you see that they purchased an ARM core for this chip so you go to arm and get the architectural reference manual and the technical reference manual. as well as any tools manuals, THEN you can start work. In those manuals you see the memory map as well as the other things you did wrong.
– old_timer
Mar 25 at 13:40
|
show 5 more comments
Code:
dest EQU 0x40000000
AREA name, CODE, READONLY
ENTRY
MOV r0, #2
LDR r1, =dest
STR r0, [r1]
stop B stop
END
This code writes the value of 2 to memory location 0x40000000.
When I change this to 0x20000000, 2 fails to get written there. Same thing with 0x3FFFFFFF. When I set the memory location to 0x40003FFF, 2 gets printed onto that location, but when I change the address to 0x40004000, 2 fails to get printed there. Same thing for any address locations higher, like 0x50000000. So according to these outputs, it seems like STR only writes values onto a finite range of memory between 0x40000000 and 0x40003FFF.
Does anyone know why this is the case? Or is there something wrong with my code? I am using Keil uVision5, NXP LPC2140.
assembly arm keil arm7
Code:
dest EQU 0x40000000
AREA name, CODE, READONLY
ENTRY
MOV r0, #2
LDR r1, =dest
STR r0, [r1]
stop B stop
END
This code writes the value of 2 to memory location 0x40000000.
When I change this to 0x20000000, 2 fails to get written there. Same thing with 0x3FFFFFFF. When I set the memory location to 0x40003FFF, 2 gets printed onto that location, but when I change the address to 0x40004000, 2 fails to get printed there. Same thing for any address locations higher, like 0x50000000. So according to these outputs, it seems like STR only writes values onto a finite range of memory between 0x40000000 and 0x40003FFF.
Does anyone know why this is the case? Or is there something wrong with my code? I am using Keil uVision5, NXP LPC2140.
assembly arm keil arm7
assembly arm keil arm7
edited Mar 25 at 1:34
phuclv
17.2k957244
17.2k957244
asked Mar 25 at 0:54
John ParkJohn Park
66
66
You read the documentation yes? what part did you not understand?
– old_timer
Mar 25 at 1:03
@old_timer Documentation? You mean Keil's reference guide for STR? Yes. You mean what happens in memory during my debugging stage? Yes.
– John Park
Mar 25 at 1:10
2
@phuclv Hmm, I think you've thrown a red herring here. The OP changes the 'dest EQU', so the R1 contains the address he wants to write into and there is no need for immediates or shifts or anything of that sort. (See keil.com/support/man/docs/armasm/armasm_dom1361289875065.htm) for LDR pseudo-instruction. I believe that write attempts fail when he attempts to write into read-only/non-existent memory or something along these lines. It's hard to comment on this without knowing the environment (I asked about this in his previous question).
– tum_
Mar 25 at 10:19
2
The "NXP LPC2140" seems to have only 16kB of SRAM (Static Random-Access-Memory) which can hold values and can be modified. Seems like it is mapped into address space at 0x40000000..0x40003FFF ... you should be able to find this "mapping" info in data sheets for your platform, or in examples coming with it. (16kiB of memory means 16384 bytes... that's probably less than this web page has, so you have to be careful when designing code for it, to use the memory effectively).
– Ped7g
Mar 25 at 11:07
1
@JohnPark the first thing you do when you start to work with a microcontroller is download the datasheet. These days and in this case and depending on vendor you also get a programmers reference manual which can vary by name, users manual, reference manual. And from those you see that they purchased an ARM core for this chip so you go to arm and get the architectural reference manual and the technical reference manual. as well as any tools manuals, THEN you can start work. In those manuals you see the memory map as well as the other things you did wrong.
– old_timer
Mar 25 at 13:40
|
show 5 more comments
You read the documentation yes? what part did you not understand?
– old_timer
Mar 25 at 1:03
@old_timer Documentation? You mean Keil's reference guide for STR? Yes. You mean what happens in memory during my debugging stage? Yes.
– John Park
Mar 25 at 1:10
2
@phuclv Hmm, I think you've thrown a red herring here. The OP changes the 'dest EQU', so the R1 contains the address he wants to write into and there is no need for immediates or shifts or anything of that sort. (See keil.com/support/man/docs/armasm/armasm_dom1361289875065.htm) for LDR pseudo-instruction. I believe that write attempts fail when he attempts to write into read-only/non-existent memory or something along these lines. It's hard to comment on this without knowing the environment (I asked about this in his previous question).
– tum_
Mar 25 at 10:19
2
The "NXP LPC2140" seems to have only 16kB of SRAM (Static Random-Access-Memory) which can hold values and can be modified. Seems like it is mapped into address space at 0x40000000..0x40003FFF ... you should be able to find this "mapping" info in data sheets for your platform, or in examples coming with it. (16kiB of memory means 16384 bytes... that's probably less than this web page has, so you have to be careful when designing code for it, to use the memory effectively).
– Ped7g
Mar 25 at 11:07
1
@JohnPark the first thing you do when you start to work with a microcontroller is download the datasheet. These days and in this case and depending on vendor you also get a programmers reference manual which can vary by name, users manual, reference manual. And from those you see that they purchased an ARM core for this chip so you go to arm and get the architectural reference manual and the technical reference manual. as well as any tools manuals, THEN you can start work. In those manuals you see the memory map as well as the other things you did wrong.
– old_timer
Mar 25 at 13:40
You read the documentation yes? what part did you not understand?
– old_timer
Mar 25 at 1:03
You read the documentation yes? what part did you not understand?
– old_timer
Mar 25 at 1:03
@old_timer Documentation? You mean Keil's reference guide for STR? Yes. You mean what happens in memory during my debugging stage? Yes.
– John Park
Mar 25 at 1:10
@old_timer Documentation? You mean Keil's reference guide for STR? Yes. You mean what happens in memory during my debugging stage? Yes.
– John Park
Mar 25 at 1:10
2
2
@phuclv Hmm, I think you've thrown a red herring here. The OP changes the 'dest EQU', so the R1 contains the address he wants to write into and there is no need for immediates or shifts or anything of that sort. (See keil.com/support/man/docs/armasm/armasm_dom1361289875065.htm) for LDR pseudo-instruction. I believe that write attempts fail when he attempts to write into read-only/non-existent memory or something along these lines. It's hard to comment on this without knowing the environment (I asked about this in his previous question).
– tum_
Mar 25 at 10:19
@phuclv Hmm, I think you've thrown a red herring here. The OP changes the 'dest EQU', so the R1 contains the address he wants to write into and there is no need for immediates or shifts or anything of that sort. (See keil.com/support/man/docs/armasm/armasm_dom1361289875065.htm) for LDR pseudo-instruction. I believe that write attempts fail when he attempts to write into read-only/non-existent memory or something along these lines. It's hard to comment on this without knowing the environment (I asked about this in his previous question).
– tum_
Mar 25 at 10:19
2
2
The "NXP LPC2140" seems to have only 16kB of SRAM (Static Random-Access-Memory) which can hold values and can be modified. Seems like it is mapped into address space at 0x40000000..0x40003FFF ... you should be able to find this "mapping" info in data sheets for your platform, or in examples coming with it. (16kiB of memory means 16384 bytes... that's probably less than this web page has, so you have to be careful when designing code for it, to use the memory effectively).
– Ped7g
Mar 25 at 11:07
The "NXP LPC2140" seems to have only 16kB of SRAM (Static Random-Access-Memory) which can hold values and can be modified. Seems like it is mapped into address space at 0x40000000..0x40003FFF ... you should be able to find this "mapping" info in data sheets for your platform, or in examples coming with it. (16kiB of memory means 16384 bytes... that's probably less than this web page has, so you have to be careful when designing code for it, to use the memory effectively).
– Ped7g
Mar 25 at 11:07
1
1
@JohnPark the first thing you do when you start to work with a microcontroller is download the datasheet. These days and in this case and depending on vendor you also get a programmers reference manual which can vary by name, users manual, reference manual. And from those you see that they purchased an ARM core for this chip so you go to arm and get the architectural reference manual and the technical reference manual. as well as any tools manuals, THEN you can start work. In those manuals you see the memory map as well as the other things you did wrong.
– old_timer
Mar 25 at 13:40
@JohnPark the first thing you do when you start to work with a microcontroller is download the datasheet. These days and in this case and depending on vendor you also get a programmers reference manual which can vary by name, users manual, reference manual. And from those you see that they purchased an ARM core for this chip so you go to arm and get the architectural reference manual and the technical reference manual. as well as any tools manuals, THEN you can start work. In those manuals you see the memory map as well as the other things you did wrong.
– old_timer
Mar 25 at 13:40
|
show 5 more comments
1 Answer
1
active
oldest
votes
I couldn't find a datasheet for "LPC2140", but I found a datasheet for what appears to be a family of devices instead, and that the specific one you have could be LPC2142/2144. The datasheet, section 6.4, shows that SRAM is mapped to 0x40000000-0x40003FFF
(assuming from what you've said that you have the 16 kB SRAM variant). That's the only address space you should be treating as general purpose RAM. Everything outside that range according to the datasheet looks scary and you should avoid it unless you fully know what you're doing.
One thing you should also be cognizant of is unaligned access. STR
writes a full word at once (4 bytes) and so the address should be aligned on a word boundary. 0x40003FFF
is not aligned to a 4-byte boundary; you should have been writing to 0x40003FFC
instead. If you just wanted to write a single byte to 0x40003FFF
, you should have used STRB
instead.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330044%2fwhy-does-str-only-work-for-addresses-between-0x40000000-and-0x40003fff%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I couldn't find a datasheet for "LPC2140", but I found a datasheet for what appears to be a family of devices instead, and that the specific one you have could be LPC2142/2144. The datasheet, section 6.4, shows that SRAM is mapped to 0x40000000-0x40003FFF
(assuming from what you've said that you have the 16 kB SRAM variant). That's the only address space you should be treating as general purpose RAM. Everything outside that range according to the datasheet looks scary and you should avoid it unless you fully know what you're doing.
One thing you should also be cognizant of is unaligned access. STR
writes a full word at once (4 bytes) and so the address should be aligned on a word boundary. 0x40003FFF
is not aligned to a 4-byte boundary; you should have been writing to 0x40003FFC
instead. If you just wanted to write a single byte to 0x40003FFF
, you should have used STRB
instead.
add a comment |
I couldn't find a datasheet for "LPC2140", but I found a datasheet for what appears to be a family of devices instead, and that the specific one you have could be LPC2142/2144. The datasheet, section 6.4, shows that SRAM is mapped to 0x40000000-0x40003FFF
(assuming from what you've said that you have the 16 kB SRAM variant). That's the only address space you should be treating as general purpose RAM. Everything outside that range according to the datasheet looks scary and you should avoid it unless you fully know what you're doing.
One thing you should also be cognizant of is unaligned access. STR
writes a full word at once (4 bytes) and so the address should be aligned on a word boundary. 0x40003FFF
is not aligned to a 4-byte boundary; you should have been writing to 0x40003FFC
instead. If you just wanted to write a single byte to 0x40003FFF
, you should have used STRB
instead.
add a comment |
I couldn't find a datasheet for "LPC2140", but I found a datasheet for what appears to be a family of devices instead, and that the specific one you have could be LPC2142/2144. The datasheet, section 6.4, shows that SRAM is mapped to 0x40000000-0x40003FFF
(assuming from what you've said that you have the 16 kB SRAM variant). That's the only address space you should be treating as general purpose RAM. Everything outside that range according to the datasheet looks scary and you should avoid it unless you fully know what you're doing.
One thing you should also be cognizant of is unaligned access. STR
writes a full word at once (4 bytes) and so the address should be aligned on a word boundary. 0x40003FFF
is not aligned to a 4-byte boundary; you should have been writing to 0x40003FFC
instead. If you just wanted to write a single byte to 0x40003FFF
, you should have used STRB
instead.
I couldn't find a datasheet for "LPC2140", but I found a datasheet for what appears to be a family of devices instead, and that the specific one you have could be LPC2142/2144. The datasheet, section 6.4, shows that SRAM is mapped to 0x40000000-0x40003FFF
(assuming from what you've said that you have the 16 kB SRAM variant). That's the only address space you should be treating as general purpose RAM. Everything outside that range according to the datasheet looks scary and you should avoid it unless you fully know what you're doing.
One thing you should also be cognizant of is unaligned access. STR
writes a full word at once (4 bytes) and so the address should be aligned on a word boundary. 0x40003FFF
is not aligned to a 4-byte boundary; you should have been writing to 0x40003FFC
instead. If you just wanted to write a single byte to 0x40003FFF
, you should have used STRB
instead.
answered Mar 28 at 21:35
Jeff EJeff E
4,32521525
4,32521525
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330044%2fwhy-does-str-only-work-for-addresses-between-0x40000000-and-0x40003fff%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You read the documentation yes? what part did you not understand?
– old_timer
Mar 25 at 1:03
@old_timer Documentation? You mean Keil's reference guide for STR? Yes. You mean what happens in memory during my debugging stage? Yes.
– John Park
Mar 25 at 1:10
2
@phuclv Hmm, I think you've thrown a red herring here. The OP changes the 'dest EQU', so the R1 contains the address he wants to write into and there is no need for immediates or shifts or anything of that sort. (See keil.com/support/man/docs/armasm/armasm_dom1361289875065.htm) for LDR pseudo-instruction. I believe that write attempts fail when he attempts to write into read-only/non-existent memory or something along these lines. It's hard to comment on this without knowing the environment (I asked about this in his previous question).
– tum_
Mar 25 at 10:19
2
The "NXP LPC2140" seems to have only 16kB of SRAM (Static Random-Access-Memory) which can hold values and can be modified. Seems like it is mapped into address space at 0x40000000..0x40003FFF ... you should be able to find this "mapping" info in data sheets for your platform, or in examples coming with it. (16kiB of memory means 16384 bytes... that's probably less than this web page has, so you have to be careful when designing code for it, to use the memory effectively).
– Ped7g
Mar 25 at 11:07
1
@JohnPark the first thing you do when you start to work with a microcontroller is download the datasheet. These days and in this case and depending on vendor you also get a programmers reference manual which can vary by name, users manual, reference manual. And from those you see that they purchased an ARM core for this chip so you go to arm and get the architectural reference manual and the technical reference manual. as well as any tools manuals, THEN you can start work. In those manuals you see the memory map as well as the other things you did wrong.
– old_timer
Mar 25 at 13:40