{"id":27059915,"url":"https://github.com/basemax/learn-assembly","last_synced_at":"2025-04-09T19:33:55.785Z","repository":{"id":286105178,"uuid":"960353865","full_name":"BaseMax/learn-assembly","owner":"BaseMax","description":"Welcome to Learning Assembly by Solving, a collection of 20 small assembly language programs designed to teach fundamental concepts through practical examples. Each program solves a specific problem, ranging from basic arithmetic to control structures, all written in x86-64 assembly using NASM syntax for Linux systems.","archived":false,"fork":false,"pushed_at":"2025-04-04T10:40:31.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T11:32:47.321Z","etag":null,"topics":["asm","assembly","assembly-lang","assembly-language","assembly-language-programming","assembly-x86","fasm","nasm"],"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/BaseMax.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":"2025-04-04T09:38:46.000Z","updated_at":"2025-04-04T10:40:34.000Z","dependencies_parsed_at":"2025-04-04T11:43:21.398Z","dependency_job_id":null,"html_url":"https://github.com/BaseMax/learn-assembly","commit_stats":null,"previous_names":["basemax/learn-assembly"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Flearn-assembly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Flearn-assembly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Flearn-assembly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Flearn-assembly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/learn-assembly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339155,"owners_count":20923014,"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":["asm","assembly","assembly-lang","assembly-language","assembly-language-programming","assembly-x86","fasm","nasm"],"created_at":"2025-04-05T13:16:55.733Z","updated_at":"2025-04-05T13:16:56.358Z","avatar_url":"https://github.com/BaseMax.png","language":"Assembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Learning Assembly by Solving\n\nWelcome to **Learning Assembly by Solving**, a collection of 20 small assembly language programs designed to teach fundamental concepts through practical examples. Each program solves a specific problem, ranging from basic arithmetic to control structures, all written in x86-64 assembly using NASM syntax for Linux systems.\n\n## Purpose\n\nThe goal is to learn assembly language by implementing solutions to common programming problems. Each `.S` file (e.g., `1.S`, `2.S`, ..., `20.S`) in the root directory corresponds to a question listed below, providing hands-on experience with low-level programming.\n\n## Questions and Solutions\n\nHere’s the list of problems solved in this repository:\n\n1. **Check if a number is even or odd**  \n   Determines the parity of a number using bitwise operations.\n\n2. **Find the maximum of two numbers**  \n   Compares two numbers and outputs the larger one.\n\n3. **Compare two numbers and print \"Equal\" if they're equal**  \n   Checks equality and prints a message accordingly.\n\n4. **Add two numbers and print the result**  \n   Performs addition and displays the sum as a character/digit (for small results).\n\n5. **Subtract two numbers and print the result**  \n   Computes the difference and outputs it.\n\n6. **Count from 1 to 5 and print each number on a new line**  \n   Uses a loop to print numbers sequentially.\n\n7. **Print the factorial of 5**  \n   Calculates 5! (120) and displays it.\n\n8. **Sum the numbers from 1 to 10**  \n   Adds numbers in a range and prints the total (55).\n\n9. **Check if a number is a multiple of 3**  \n   Tests divisibility by 3 and outputs the result.\n\n10. **Print the first 5 even numbers**  \n    Lists 0, 2, 4, 6, 8 with a loop.\n\n11. **Reverse a 2-digit number (e.g., 42 → 24)**  \n    Swaps the digits of a two-digit number.\n\n12. **Convert a single digit (0-9) to ASCII and print it**  \n    Transforms a digit to its ASCII character for output.\n\n13. **Print \"Positive\" or \"Negative\" based on a signed number**  \n    Determines the sign of a number and prints the appropriate label.\n\n14. **Calculate and print 2^n for small n (like 0–5)**  \n    Computes powers of 2 (1, 2, 4, 8, 16, 32) and displays them.\n\n15. **Check if a number is prime (try for small ones like 2–10)**  \n    Tests primality for small integers.\n\n16. **Store 5 numbers in memory and find their sum**  \n    Sums an array of 5 numbers.\n\n17. **Swap two variables using a temporary register**  \n    Exchanges the values of two variables.\n\n18. **Find the average of 3 numbers**  \n    Calculates the integer average of three numbers.\n\n19. **Print the alphabet A to E using a loop**  \n    Outputs A, B, C, D, E on separate lines.\n\n20. **Take two numbers and print which one is closer to 10**  \n    Compares distances from 10 and prints the result.\n\n## Files\n\nThe repository contains 20 assembly source files in the root directory:\n- `1.S`, `2.S`, `3.S`, ..., `20.S`\n\nEach file corresponds to the question number above and contains a standalone program written in x86-64 assembly.\n\n## How to Run\n\nTo compile and execute these programs on a Linux system with NASM installed:\n\n1. **Assemble**:  \n   ```bash\n   nasm -f elf64 \u003cfilename\u003e.S -o \u003cfilename\u003e.o\n   ```\n   Example: nasm -f elf64 1.S -o 1.o\n\n2. **Link:**\n\n  ```bash\n  ld \u003cfilename\u003e.o -o \u003cfilename\u003e\n  ```\n  Example: ld 1.o -o 1\n\n3. **Run:**\n\n  ```bash\n  ./\u003cfilename\u003e\n  ```\n  Example: ./1\n\n## Prerequisites\n\n- NASM: The Netwide Assembler (install with sudo apt install nasm on Ubuntu/Debian).\n- Linux: These programs target x86-64 Linux systems using system calls (e.g., write, exit).\n\nOr try online compilers such as https://onecompiler.com/assembly/43dsexwn3\n\n## Contributing\n\nFeel free to fork this repository, submit pull requests, or open issues for suggestions and improvements. Contributions are welcome!\n\n## Acknowledgments\n\nCreated as a learning exercise by Max Base to explore assembly language programming. Inspired by fundamental programming challenges adapted to the low-level environment.\n\n## License\n\nCopyright © 2025 Max Base. This project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Flearn-assembly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Flearn-assembly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Flearn-assembly/lists"}