{"id":15060214,"url":"https://github.com/shikha-code36/assembly-arm-tutorial","last_synced_at":"2026-01-03T01:04:12.793Z","repository":{"id":244657395,"uuid":"815118782","full_name":"Shikha-code36/assembly-ARM-tutorial","owner":"Shikha-code36","description":"A Beginner’s Guide to Assembly ARM language","archived":false,"fork":false,"pushed_at":"2024-06-18T12:18:46.000Z","size":293,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T05:14:42.705Z","etag":null,"topics":["arm","armv7","asm","assembler","assembly","assembly-language","assembly-language-programming","assemblyscript","gdp","linux-debian","raspberry","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shikha-code36.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-14T11:47:26.000Z","updated_at":"2025-01-12T13:42:07.000Z","dependencies_parsed_at":"2024-06-16T13:51:59.613Z","dependency_job_id":"778cf8bf-0d55-421c-ae8d-d47d56d2840a","html_url":"https://github.com/Shikha-code36/assembly-ARM-tutorial","commit_stats":null,"previous_names":["shikha-code36/assembly-arm-tutorial"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2Fassembly-ARM-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2Fassembly-ARM-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2Fassembly-ARM-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2Fassembly-ARM-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shikha-code36","download_url":"https://codeload.github.com/Shikha-code36/assembly-ARM-tutorial/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243685583,"owners_count":20330982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arm","armv7","asm","assembler","assembly","assembly-language","assembly-language-programming","assemblyscript","gdp","linux-debian","raspberry","raspberry-pi"],"created_at":"2024-09-24T22:54:32.981Z","updated_at":"2026-01-03T01:04:12.758Z","avatar_url":"https://github.com/Shikha-code36.png","language":"Assembly","readme":"# Guide to ARM Assembly Language\n\n## Introduction\nARM assembly language is a low-level programming language designed for ARM (Advanced RISC Machine) processors, which are prevalent in embedded systems like smartphones and laptops. It enables direct interaction with the hardware, offering precise control over the device's operations.\n\nIt is estimated that over 200 billion devices contain an ARM chip, making the arm language valuable to understand. By understanding the arm assembly language, programmers can work at a lower level, allowing them to write code that interacts with hardware in an efficient manner. Arm is a programming language that's used in a variety of different applications. You see it in a lot of different embedded devices. And really popular devices such as different phones, a lot of Android devices and some iPhone devices are running ARM based chips.\n\n## Registers\nRegisters are fast-access storage locations within the CPU that hold data temporarily during execution. They play a crucial role in assembly language programming due to their speed compared to memory access.\n\n### General-Purpose Registers (R0-R6)\n- **R0-R6**: Used for general computations and temporary storage.\n- **Example**: Storing and adding numbers.\n  ```assembly\n  MOV R0, #5    ; Move 5 into R0\n  MOV R1, #10   ; Move 10 into R1\n  ADD R2, R0, R1; Add R0 and R1, result in R2 (R2 = 15)\n  ```\n\n### Special-Purpose Registers\n- **R7**: System Call Register for OS services.\n  ```assembly\n  MOV R7, #1    ; System call number for program exit\n  SWI 0         ; Invoke system call\n  ```\n- **SP (Stack Pointer)**: Points to the stack's top for managing function calls and local variables.\n  ```assembly\n  PUSH {R0}     ; Push R0 onto the stack\n  POP {R0}      ; Pop from stack into R0\n  ```\n- **LR (Link Register)**: Holds the return address for functions.\n  ```assembly\n  BL function   ; Call 'function', store return address in LR\n  ```\n- **PC (Program Counter)**: Points to the next instruction.\n  ```assembly\n  LDR PC, [R0]   ; Load address into PC from R0\n  ```\n\n### CPSR (Current Program Status Register)\nStores flags indicating conditions after operations, like negative or zero results. It guides conditional execution based on these flags.\n\n**Example**: Using flags for conditional branching.\n```assembly\nCMP R0, R1     ; Compare R0 and R1\nBEQ label      ; If equal (Zero flag set), branch to 'label'\n```\n\n## Memory Sizes\n- **Word**: Maximum data size for a register (32 bits on a 32-bit processor).\n- **Half-word**: Half of a word (16 bits).\n- **Byte**: Always 8 bits.\n\n## Stack Memory\nA slower but larger capacity memory used for complex data like arrays. Managed using the stack pointer (SP).\n\n## Detailed Register Usage Examples\n\n### Using General-Purpose Registers\n```assembly\nMOV R3, #15   ; Store 15 in R3\nMOV R4, #20   ; Store 20 in R4\nMUL R5, R3, R4; Multiply R3 by R4, result in R5 (R5 = 300)\n```\n\n### Managing Function Calls with LR and SP\n```assembly\nPUSH {LR}     ; Save LR before function call\nBL some_func  ; Call 'some_func', LR updated with return address\nPOP {LR}      ; Restore LR after function return\n```\n\n### Conditional Execution with CPSR Flags\n```assembly\nSUBS R6, R4, R3; Subtract R3 from R4, update flags based on result\nBMI negative   ; Branch to 'negative' if result is negative (Negative flag set)\n```\n\nThis guide provides an organized overview of ARM assembly language programming concepts.Beginners can use this as a foundation for further learning and practice in ARM assembly programming.\n\n\n### File Extensions for ARM Assembly\n\n- **.s**: Use this extension for ARM assembly code files intended for the GNU Assembler (GAS), which is part of the GNU toolchain commonly used on Linux systems, including the Raspberry Pi.\n\n- **.asm**: This extension can also be used for assembly code files but is more commonly associated with Intel syntax and assemblers like NASM or MASM. For ARM assembly on Raspberry Pi, `.s` is the preferred extension when using GAS.\n\n## Comprehensive ARM Assembly Programming Guide\n\nThis section outlines the complete journey of learning ARM Assembly Language, from writing your first program to advanced hardware interactions and debugging techniques.\n\n- [x] [First Program](first_program)\n- [x] [Addressing Modes](addressing_modes)\n- [x] [Arithmetic and CPSR Flags](arithmetic_and_cpsr_flags)\n- [x] [Logical Operations](logical_operations)\n- [x] [Logical Shifts and Rotations](logical_shifts_and_rotations)\n- [x] [Conditions and Branches](conditions_and_branches)\n- [x] [Loops with Branches](loops_with_branches)\n- [x] [Conditional Instruction Execution](conditional_instruction_execution)\n- [x] [Branch with Link Register and Returns](branch_with_link_register_and_returns)\n- [x] [Preserving and Retrieving Data From Stack Memory](preserving_and_retrieving_data_from_stack_memory)\n- [x] [Hardware Interactions](hardware_interactions)\n- [x] [Setting Up QEMU for ARM](setting_up_qemu_for_arm)\n- [x] [Printing Strings to Terminal](printing_strings_to_terminal)\n- [x] [Debugging Arm Programs with Gdb](debugging_arm_programs_with_gdb)\n\n## Acknowledgements\n\nThis guide is based on the video tutorial by Scott Cosentino. You can watch the full tutorial [here](https://youtu.be/gfmRrPjnEw4?si=WZeq4fv6NHZRJnpT) and visit his channel [Olive Stem Learning](https://www.youtube.com/@olivestemlearning) for more educational content.\n\nA special thanks to Scott Cosentino for the comprehensive tutorial on ARM assembly language.\n\n## Show Your Support\n\nIf you found this guide helpful, please consider starring the repository to show your support. Your star helps increase visibility and encourages more learners to discover and benefit from these educational resources.\n\n## License\n\nThis project is released under the [MIT License](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshikha-code36%2Fassembly-arm-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshikha-code36%2Fassembly-arm-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshikha-code36%2Fassembly-arm-tutorial/lists"}