Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ebodshojaei/calculator-in-c
Basic calculator in C that operates on integer operands based on user input.
https://github.com/ebodshojaei/calculator-in-c
asm assembly c
Last synced: 30 days ago
JSON representation
Basic calculator in C that operates on integer operands based on user input.
- Host: GitHub
- URL: https://github.com/ebodshojaei/calculator-in-c
- Owner: EbodShojaei
- Created: 2023-10-31T17:57:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-01T04:33:12.000Z (over 1 year ago)
- Last Synced: 2024-11-15T08:20:58.594Z (3 months ago)
- Topics: asm, assembly, c
- Language: Assembly
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Calculator in C
## About
Basic calculator in C that operates on integer operands based on user input.
- Includes functions for simple operations (i.e., addition, subtraction, multiplication, and division).
- Error handles invalid inputs (e.g., non-numeric, divide-by-0).
- Accepts user input for operands and operation.**Note:** *Repository includes C and assembly source files.*
## How to Run C Code
// First command generates executable.
// Second command runs executable.
gcc calculator.c -o calculator.o
./calculator.o## How to Run Assembly Code
### Extended ASM (current)
// Converts to extended assembly syntax using GCC (current).
//
// First command disassembles C into extended assembly syntax with GCC.
// Second command generates executable.
// Third command runs executable.
//
// **NOTE: for syntax @see https://www.felixcloutier.com/documents/gcc-asm.html
// **NOTE: for -pie @see https://stackoverflow.com/a/30426603/22279004
// **NOTE: -S disassembles C code into extended assembly syntax (does not support nasm, masm, fasm, tasm)
gcc -S calculator.c -o calculator.s
gcc -o calculator calculator.s -pie
./calculator
### NASM (deprecated)
// Compiles and executes assembly in NASM syntax (deprecated).
//
// First command assembles NASM (Netwide Assembler).
// Second command generates executable.
// Third command runs executable.
//
// ** NOTE: -felf64 specifies the output format as ELF64 (Executable and Linkable Format for 64-bit architectures).
nasm -felf64 Calculator2.asm
ld Calculator2.o -o Calculator2
./Calculator2