Giter Site home page Giter Site logo

shlomi1993 / assemblyproject Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 262 KB

This repo documents an implementation of P-String and realated functions in Assembly language as part of Computer Structure course I took at Bar-Ilan university.

Makefile 0.87% C 8.81% Assembly 80.25% Shell 10.07%
assembly computer-structure

assemblyproject's Introduction

AssemblyProject

This repo documents an implementation of P-String and realated functions in Assembly language as part of Computer Structure course I took at Bar-Ilan university.

Background

P-String is a way to save string as an array of chars where the first byte represents the length of the string:

typedef struct {
    char size;
    char string[255];
} Pstring;

In this repo I've implemented a P-String smilar to those in string.h library, but using assembly language.

P-String in the Stack

The pstring "hello" will be stored in the stack as:

image

Files

  1. run_main.s -- program's entry.
  2. pstring.s -- implementations of library functions.
  3. func_select.s -- implementation of a function that call other functions.

Program's Structure

run_main() gets two strings and two lengths from the user, build two pstrings and send them to run_func() in func_select.s. run_func uses a jump-table (switch-case) to determine what function from pstring.s to use.

Jump-Table / Switch-Case Options:

  • 50 / 60 -- pstrlen -- prints the length of the pstring (return the first byte).
  • 52 -- replaceChar -- replace a specific char in the p-string.
  • 53 -- pstrijcpy -- copy sub-string between index i to index j to another pstring.
  • 54 -- swapCase -- change case of English characters.
  • 55 -- pstrijcmp -- compare strings from index i to index j.

Notes

  • The code is heavily commented.
  • IDE: Visual Studio Code.
  • Useful document in resources directory: CS107 Handy one-page of x64-86.

assemblyproject's People

Contributors

shlomi1993 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.