Giter Site home page Giter Site logo

calculator-in-c's Introduction

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

calculator-in-c's People

Contributors

ebodshojaei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.