Posts

Showing posts from November, 2021

SPO600 64-bit Assembler (Week 5 Lab)

Image
 In this lab, we go over the basics of the 64-bit assembler. The first instruction is to unpack code examples provided in a directory of the following structure:

6502 Assembly Language Strings (Week 4 Lab)

Hi everyone, and welcome back to my SPO600 blog. This is the final 6502 lab. In this lab, we learnt about how strings work in 6502, which involves character conversions. The purpose of this lab is to prepare us for learning the more complex x86_64 and AArch64 assembly languages.

I'm becoming an expert at 6502 Assembly

Image
We're almost a month into SPO600, and 6502 Assembly concepts are really starting to become second nature for me. In this lecture, Chris spoke about characters, strings, and system routines. Characters are usually represented in binary as a number which corresponds to an entry in a character set table. The most common table is ASCII. Strings are groups of characters terminated with zeroes, much like C. There are several ROM (read-only memory) system routines for the 6502 emulator: SCINIT $ff81 - Initialize and clear the character display CHRIN $ffcf - Input one character from keyboard (returns A) CHROUT $ffdw - Outputs one character (A) to the screen at the current cursor position. Screen will wrap/scroll appropriately. Printable characters and cursor codes ($80/$81/$82/$83 for up/right/left/down) as well as RETURN ($0d) are accepted. Printable ASCII codes with the high bit set will be printed in reverse video. SCREEN $ffed - Returns the character screen size in the X and Y

6502 Math Lab (Week 3 Lab)

Hello everybody, and welcome to the third lab of SPO600. After studying 6502 directives last class, specifically DCB, we're going to use it this lab in our very first creative piece of work using 6502. The objective in this lab is to create a graphic animation using the 6502 emulator colors. We're given four options to achieve this: Bouncing Graphic Numeric Display Pong Kaleidoscope I've decided to go with the bouncing graphic. To achieve my design, I copied the code example to display a ball on the screen. This code sample uses DCB to pre-define all the locations and load them into the a register. define WIDTH 4 ; width of graphic define HEIGHT 4 ; height of graphic lda #$25 ; create a pointer at $10 sta $10 ; which points to where lda #$02 ; the graphic should be drawn sta $11 lda #$00 ; number of rows we've drawn sta $12 ; is stored in $12 ldx #$00 ; index for data ldy #$00 ; index for screen column draw: lda data,x sta ($10),y

Week 02 of 6502!

Hey guys, and welcome back to my SPO600 blog. In this class, we took a deeper dive into 6502 Assembler. This time, we learnt some directives. Directives are instructions that set behavior for how the compiler processes input. Here's a few examples. define This directive is a very simple text replacement, which stores a given value into any word you provide to it. For example, 'define WHITE $01' makes it so that any time you mention 'WHITE', it gets substituted with $01. This is really useful if some particular values are hard to remember. In this case, $01 refers to the white color, which is definitely easy to forget. DCB DCB (define constant byte) stores a value in memory, at the very end of the memory. Once that value is declared, it can be called from the main code using LDA. The value must be either a quoted string or a numeric expression that evaluates to an integer between 128 to 255. I was interested to see the parallels between 6502 directives and C++ direct

6502 Assembly Language (Week 2 Lab)

In this lab, we took our first baby steps in the 6502 universe. The idea was to mess around with the 6502 simulator, and finish by drawing four different coloured lines around the edges of the given square field. Here is a link to the simulator: http://6502.cdot.systems/ I came up with some pretty simple code to accomplish this, and I've written some comments in the code to explain my thought process. define GREEN $5 define BLUE  $6 define YELLOW $7 define PURPLE $8 ; set low and high bits for the beginning of the screen define start_lowbit $00 ; low define start_highbit $02 ; high ; 0200 is the address of the first pixel define first_pixel_lowbit $0  ; define first_pixel_highbit $1 ; define index_at_end_of_row $20 ; this is decimal 32, because the screen is 32px wide       ; because 6502 is little-endian, 2 byte values are stored with low bit first       lda #start_lowbit ;       sta first_pixel_lowbit ; sta stores value of register A into RAM       lda #start_highbit       sta

Binary: How low can you go?

 In this lecture, Chris spoke about binary representation, the lowest level of data representation. I've always been enamored by graphical representation using bits and bytes, as I've dealt a lot with RGB for web development and graphic editing, so I was pleasantly surprised to see this topic. From what I learnt, several types of data may be encoded in binary: Binary uses 'bits', which stands for binary digits (that second part blew my mind!)  either 0 or 1 resistant to errors Integers stored as groups of 8 bits, known as 'bytes' starting from right to left at 0, each bit represents a value of 2^(bit number) e.g. 10010111 = 1x2 7 + 0x2 6 + 0x2 5 + 1x2 4 + 0x2 3 + 1x2 2 + 1x2 1 + 1x2 0 = 151 Fixed-point encoded the same way as integers, but the bits to the right of the decimal point are 'fractional' Floating-point encoded in three parts: the sign bit, the mantissa, and the exponent 0 represents a positive sign bit, whereas 1 is negative common flo

The World of Open Source! (Week 1 Lab)

In SPO600, we'll be submitting our own code for review. In order to learn more about this, Lab 1 is designed to explore the code review processes used in open source projects. I looked into two open source software packages - AForge.NET, a .NET computer vision library and YARP.it, a C++ robotics library. I took a closer look and found that AForge.NET has a public GitHub repo to accept pull requests. Interestingly, I found 10 pull requests. One of them, titled 'Added new solution and project files for .NET Standard' had four replies discussing specific technicalities I won't go over. On YARP.it, it was really easy to find their GitHub repo because it's on their main page. This time, there were 14 pull requests. The first one had 15 replies, in which they had an argument on whether or not the pull request is even beneficial or necessary. Although the pull request was made over 2 years ago, it's still in progress. It seems that there hasn't been a reply since M

SPO600 Introduction

 Hi, and welcome to my SPO600 blog! This course is about software optimization, and dives into a lot of low-level technologies such as AArch64 and x86_64 to help us understand how software can run on different architectures, as well as how optimizations can be made to increase performance. Today, I generated a pair of SSH keys and emailed Chris, the professor, the public key so that I get access to the systems I will be using to develop code in class. SPO600 seems really technical, but I'm already pretty interested so let's give it my best!