Create an object at a given address: Difference between revisions
Create an object at a given address (view source)
Revision as of 10:24, 12 September 2021
, 2 years agono edit summary
Puppydrum64 (talk | contribs) No edit summary |
Puppydrum64 (talk | contribs) No edit summary |
||
Line 108:
</lang>
=={{header|ARM Assembly}}==
{trans|68000 Assembly}
First, an integer object will be created at address $100000:
<lang ARM Assembly>mov r0,#0x00100000
ldr r1,testData
str r1,[r0] ;store 0x12345678 at address $100000
bx lr ;return from subroutine
testData:
.long 0x12345678 ;VASM uses .long for 32 bit and .word for 16 bit values, unlike most ARM assemblers.</lang>
Finding the address of a given object isn't actually possible in the same way it would be on [[C]], since anything loaded from an address is just a numeric copy and is not actually related in any way to the "object." The closest way is to label a memory address and load that label as a numeric constant.
<lang ARM Assembly>.equ myVariable,0x00100000
mov r0,#myVariable
bl printLong ;unimplemented printing routine</lang>
Creating a new object at that location is as simple as storing a new value there.
<lang ARM Assembly>mov r0,#0x00100000
mov r1,#0
mvn r1,r1 ;flip the bits of r1
str r1,[r0] ;store 0xFFFFFFFF at address $100000
bx lr ;return from subroutine</lang>
=={{header|AutoHotkey}}==
|