https://github.com/abdullah-niaz/coal
Explore basic assembly language concepts and examples, including fundamental operations, NASM syntax, and low-level programming.
https://github.com/abdullah-niaz/coal
assemblylanguage lowlevelprogramming nasm systemprogramming
Last synced: 7 months ago
JSON representation
Explore basic assembly language concepts and examples, including fundamental operations, NASM syntax, and low-level programming.
- Host: GitHub
- URL: https://github.com/abdullah-niaz/coal
- Owner: Abdullah-Niaz
- Created: 2024-08-20T04:38:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-15T18:06:01.000Z (10 months ago)
- Last Synced: 2025-01-17T10:28:15.126Z (9 months ago)
- Topics: assemblylanguage, lowlevelprogramming, nasm, systemprogramming
- Language: Assembly
- Homepage:
- Size: 52.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Run on VsCode(linux)
#### Assemble the Program
In the terminal, navigate to the directory containing hello.asm and run the following command to assemble the code into an object file:
`nasm -f elf32 -o hello.o hello.asm`
#### Link the Object File:
Use the linker to create an executable from the object file:
`ld -m elf_i386 -o hello hello.o`#### Run the Program:
Finally, execute the program:
`./hello`#### Summary:
1. You installed NASM and GCC.
2. Wrote an assembly program in VS Code.
3. Assembled it using nasm.
4. Linked it using ld.
5. Ran it to print "Hello, World!" in the terminal.---
### Assemble and Link on Ubuntu Using NASM:
Open a terminal on Ubuntu and run:
`nasm -f bin filename.asm -o filename.com`
This command converts your assembly code to a `.com` file.
### Run the Executable in DOSBox
After assembling the `.com` file, you can run it within DOSBox:
#### i. Mount the Directory in DOSBox
`mount c /path/to/your/directory
c:`#### ii. Run the Program
`filename.com`
---
---
## Window
`nasm file.asm -o file.com`
#### Listing
`nasm file.asm -o file.com -l file.lst`
#### Run:
`file.com`
#### For Degugger
`afd file.com`
## Ubuntu
### 1. Assemble the File:
If your file uses modern NASM syntax and is correctly formatted, assemble it like this:
`nasm -f elf64 yourfile.asm -o yourfile.o`
### 2. Link the Object File:
For first one
` ld -o yourfile yourfile.o`
### 3. Run the Executable
` ./yourprogram`
### 4. Checking for Common Issues
If you encounter issues, consider the following:
#### i. File Paths:
Ensure that the file paths used in the mov rsi, msg instruction correctly point to the message in your .asm file.
#### ii. Syscall Numbers:
Verify that the syscall numbers used (1 for sys_write and 60 for sys_exit) are correct for your system.
#### iii. Permissions:
Ensure the executable has execute permissions. If not, set the correct permissions using:
` chmod +x yourprogram`
### 5. Debugging
If you encounter issues or need to debug your assembly program, follow these steps:
#### i. Assemble with Debug Information
Generate debugging information during the assembly process:
`nasm -f elf64 -g yourfile.asm -o yourfile.o `
#### ii. Link with Debug Information
`ld -g -o yourprogram yourfile.o 3. `
#### iii. Run in gdb
Use gdb (GNU Debugger) to debug your program:
`gdb ./yourprogram`
Inside gdb, you can set breakpoints and step through the code to identify where it might be failing. For example:
**Set a Breakpoint:** `break \_start`
**Run the Program:** `run`
**Step Through Code:** `step`
**Continue Execution:** `continue`
**Print Registers or Variables:** `print rax` (or other registers)