Giter Site home page Giter Site logo

hex-to-bcd's Introduction

HEX-to-BCD

Assembly x86 program for conversion of HEX number to BCD format and vice versa.

Step 1: Install NASM for executing the code.(https://www.youtube.com/watch?v=ooJfdrds9Dk)

Step 2: Open terminal and execute following commands to run the program:
nasm -f elf64 filename.asm
ld -o x numadd.o
./x

Algorithm For Hex to BCD Conversion
Step I : Initialize the data segment.
Step II : Initialize BX = 0000 H and DH = 00H.
Step III : Load the number in AX.
Step IV : Compare number with 10000 decimal. If below goto step VII else goto step V.
Step V : Subtract 10,000 decimal from AX and add 1 decimal to DH
Step VI : Jump to step IV.
Step VII : Compare number in AX with 1000, if below goto step X else goto step VIII.
Step VIII : Subtract 1000 decimal from AX and add 1000 decimal to BX.
Step IX : Jump to step VII.
Step X : Compare the number in AX with 100 decimal if below goto step XIII
Step XI : Subtract 100 decimal from AX and add 100 decimal to BX.
Step XII : Jump to step X
Step XIII : Compare number in AX with 10. If below goto step XVI
Step XIV : Subtract 10 decimal from AX and add 10 decimal to BX.
Step XV : Jump to step XIII.
Step XVI : Add remainder in AX with result in BX.
Step XVII : Display the result in DH and BX.
Step XVIII : Stop.

Algorithm For BCD to Hex Conversion
Step I : Initialize the data segment.
Step II : Load the MSB of word in register AX.
Step III : Compare it with 0, if zero goto step VII else goto step IV.
Step IV : decrement AX and initialize BX = 0000.
Step V : add 10000 decimal to BX.
Step VI : Jump to step III.
Step VII : Load LSB of word in register AX.
Step VIII : Compare it with 1000, if below go to step XII else go to step IX.
Step IX : subtract 1000 H from AX.
Step X : Add 1000 decimal to BX.
Step XI : Jump to step VIII
Step XII : Compare number in AX now with 100 H, if below go to step XVI, else go to step XIII.
Step XIII : Subtract 100 H from AX.
Step XIV : Add 100 decimal to BX.
Step XV : Jump to step XII.
Step XVI : Compare number in AX with 10H, if below go to step XX, else go to step XVII.
Step XVII : Subtract 10 H from AX
Step XVIII : Add 10 decimal to BX
Step XIX : Jump to step XVI
Step XX : Add contents of AX and BX.
Step XXI : Display the result.
Step XXII : Stop.

hex-to-bcd's People

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.