Comments (3)
Thank-you VERY, VERY, VERY much. That worked perfectly and I've modified my program to now grab the command line argument(s) entered and act on them accordingly.
Again....thanks tons. Much appreciated!!!!!!
from hellosilicon.
Gladly, it is quite easy. This is the entry function:
int main (int argc, const char * argv[])
As per the standard ARM64 ABI, the arguments are in the registers:
x0
holds argc
x1
holds argv
Let's invoke our executable with lldb HelloSilicon foo
, and look at the register when our _start
routine is called:
(lldb) re r sp x0 x1
sp = 0x000000016fdff970
x0 = 0x0000000000000002
x1 = 0x000000016fdff9a0
As you can see, x0 contains 2, and x1 points to a position 48 bytes above the current SP (and we can find the value for argc at 40 bytes, too).
When we examine the memory pointed to at x1, we see the elements of argv, which are in turn pointers:
(lldb) m read -fx -c32 0x000000016fdff9a0
0x16fdff9a0: 0x6fdffb20 0x00000001 0x6fdffb53 0x00000001
The memory pointed to by the doubleword at x1 contains, as expected, the full path to the executable:
(lldb) m read -fc -c51 0x000000016fdffb20
0x16fdffb20: /Users/below/dev/HelloSilicon/Ch
0x16fdffb40: apter 1/HelloWorld\0
And finally, the doubleword at [x1, #8] points to our argument, foo:
(lldb) m read -fc -c4 0x000000016fdffb53
0x16fdffb53: foo\0
With this information, it should be easy to adopt your code! Let me know if it works!
from hellosilicon.
Please see my adaption of your code in Chapter 4/case.s and feel free to add or edit it
from hellosilicon.
Related Issues (16)
- Chapter 13, NEON: Invalid operand for instruction MUL HOT 2
- openat syscall not working HOT 1
- Linking failing after installing Big Sur 11.0.1 HOT 5
- can't use the command `objdump` command with no-aliases option HOT 3
- 'Hello world' doesn't work on silicon HOT 3
- build 32-bit binary on Apple Silicon Mac HOT 4
- GAS generates local symbols for labels starting with the letter L
- Authoritative documentation of assembler for M1 machines? HOT 8
- objdump's `--macho` option makes `-M no-aliases` have no effect?
- Brief explanation of changes HOT 2
- incorrect `chapter4::printword.s` assembly program HOT 2
- Opting out of libc on Apple Silicon HOT 7
- issue #49: incorrect fix HOT 2
- write on Linux requires a length HOT 1
- Change "as" to "clang" in all examples HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hellosilicon.