Hello, I studied Computer Science, and now I live in Bath. I write code, design games, and occasionally tweet. RSS Feed
Hello, I studied Computer Science, and now I live in Bath. I write code, design games, and occasionally tweet. RSS Feed

Posts about Programming Other Categories

25 Days, 25 Languages

Dec. 1, 2018 in Programming, Text

This year I am going to take part in the 2018 Advent of Code, where each day, two new programming challenges are uploaded to the site. But as I live in the UK and I don’t want to ruin my sleeping schedule for a month, competing for the leaderboard is out of the question. Instead, I am going to challenge myself to use 25 different programming languages.

For this I will treat different versions of the same language as the same language, so no Python 2 and Python 3 solutions. However, I can use C, C++, and C# as they are all different languages, even if they are rather similar syntactically. As for what language I pick on the day, it really depends how I am feeling. If the problem is simple, I am more likely to choose a more complex or unfamiliar language. I’ll be saving some language for when I am really struggling.

My solutions will be posted on GitHub.

Edit: Oops, so that didn’t happen. Not long after starting this challenge I broke my dominant wrist roller-skating, and just in time for Christmas! But anyway, this means that it is unlikely that I will finish this. While incomplete, I am glad I attempted it and will definitely consider using Rust in future projects - it is a nice language.

The Little Man Computer

Apr. 12, 2011 in Programming

The Little Man Computer (LMC) is an instructional model of a computer, created by Dr. Stuart Madnick in 1965. The LMC is generally used to teach students, because it models a simple von Neumann architecture computer - which has all of the basic features of a modern computer. It can be programmed in machine (albeit usually in decimal) or assembly code.

Screenshot of the Program

For reference, here is some example code that takes numbers as input, and squares the result. Credit Wikipedia.

START   LDA ZERO     // Initialize for multiple program run
        STA RESULT
        STA COUNT
        INP          // User provided input
        BRZ END      // Branch to program END if input = 0
        STA VALUE    // Store input as VALUE
        ADD VALUE    // Add VALUE, the user provided input, to RESULT
        STA RESULT   // Store the new RESULT
        LDA COUNT    // Load the COUNT
        ADD ONE      // Add ONE to the COUNT
        STA COUNT    // Store the new COUNT
        SUB VALUE    // Subtract the user provided input VALUE from COUNT
        BRZ ENDLOOP  // If zero (VALUE has been added to RESULT by VALUE times), branch to ENDLOOP
        BRA LOOP     // Branch to LOOP to continue adding VALUE to RESULT
        OUT          // Output RESULT
        BRA START    // Branch to the START to initialize and get another input VALUE
END     HLT          // HALT - a zero was entered so done!
RESULT  DAT          // Computed result (defaults to 0)
COUNT   DAT          // Counter (defaults to 0)
ONE     DAT 1        // Constant, value of 1
VALUE   DAT          // User provided input, the value to be squared (defaults to 0)
ZERO    DAT          // Constant, value of 0 (defaults to 0)

In the absence of any Windows desktop emulator, I created my own in .NET and here it is. View and download on GitHub.