Git Product home page Git Product logo

helloworld's Introduction

helloworld

Hello World, using 6 different methods in Assembler on Raspberry Pi, in varying levels of complexity. Chooose your Linux, and these should work without alteration.

A makefile has been included to simplify compilation. Tested only on Raspberry Pi 3 and 4 (Raspbian) as specified in the source file name, but they should all work on the other models just fine since there isn't anything particularly advanced going on.

These are all straight up "normal" ways, although each one shows a completely different medhod for getting there. The code is clean and quite straight forward. There are probably better ways to do some of the things I came up with, but this is about doing only one thing - printing "Hello, World!" on its own line. Take it as a challenge, and show me your ideas if you can think of other methods not included here.

hw-rpi3-1

Hello World using puts(). Notice it doesn't need a carriage return, while the other methods do. The puts() call is rather slobber-proof.

hw-rpi3-2

Hello World using write(). I suspect this is the more typical method.

hw-rpi3-3

Hello World using fwrite(). fwrite() is typically used to work with binary data instead of text mode. Of course, ascii is made up of binary, so it works perfectly well for spitting out letters, spaces and punctuation, too.

hw-rpi3-4

Hello World using putchar(). This is closer to how the computer actually does it deep down inside. I had to use a goto to initiate the loop because ARM doesn't do jz in the same way as Intel. It is strangely easier to reverse the flow and jump if not zero.

hw-rpi3-5

Hello World bypassing clib altogether. [NOTE: Previous description was incorrect. Updating shortly.]

hw-rpi4-6

Hello World using printf(). I wrote this on my new rpi4, but it should work on the others, too. This method makes sense when you want to use format strings. Otherwise it is probably overkill. Here we've just used \n for the newline, but with printf you have a whole lot of interesting % variables at your disposal.

Resources

Since uploading the first bunch of these, I have discovered a few good resources on ARM assembler for the RPI. Here is one that seems to follow a good process for learning, and goes more in depth than any of the others I found: https://thinkingeek.com/arm-assembler-raspberry-pi/

helloworld's People

Contributors

ksaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

benjamin-ky

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.