Tuesday 14 January 2020

Week 1 - Lecture

The first week's lecture started with giving us an insight of how different forms of data was interpreted by the machines. Integers are interpreted in the forms bits as the combination of 0's and 1's. Same as integers, characters were also represented by the 0's and 1's as bits and it's value was figured out by using the ASCII table. Digital sounds are represented as series of time based measurements which was called Pulse Coded Modulation. but as PCM took alot of storage, sound was compressed by either lossless or lossy modes of compressions. Images are represented as collection of pixels which in turn are made of combination of RGB colors ranging from 0-255 giving a total of 16 million color combinations. Same as sound raw storage of graphics took alot of space so they could also be compressed by either lossless or lossy compressions. Videos are interpreted as moving images and can be compressed by encoding differences between each frame. Different compression techniques which could be applied on these are listed here:
https://wiki.cdot.senecacollege.ca/wiki/Winter_2020_SPO600_Weekly_Schedule#Week_1_-_Class_II

Moving on we were introduced to 1970's processor which was 6502. Here is a introduction about the same if you guys are interested: https://wiki.cdot.senecacollege.ca/wiki/6502.
We were then taught that the processor was divided into different sections, first 0-100 for storing the variables, 100-200 was the stack, 200-600 was the bitmapped display. There are 3 registers on this processor that we can work with which were A, X and Y.

Then we were shown the emulator for 6502 (http://6502.cdot.systems/) that were dealing with in the first few weeks of this course. Here is the first program we were shown for this course:
lda #$00 ; set a pointer at $40 to point to $0200
 sta $40
 lda #$02
 sta $41

 lda #$07 ; colour

 ldy #$00 ; set index to 0

loop: sta ($40),y ; set pixel

 iny  ; increment index
 bne loop ; continue until done the page

 inc $41  ; increment the page
 ldx $41  ; get the page
 cpx #$06 ; compare with 6
 bne loop ; continue until done all pages

This code fills the bitmapped display with the color yellow.

Explanation:
Starting from the top, the lda instruction loads the accumulator with number 00 (Note: starting with $ is a hexa decimal address and starting with # is just a hexa decimal number). the second instruction sta stores that instruction at address 40, which is repeated on next two instructions, putting 02 at adjacent address 41. This combination acts as a pointer thus pointing to 0200 (aligned little endian) which is the start of the display.
After this, the instruction lda loads the accumulator with number 07 which is for the color yellow. and ldy sets the index at 0 at Y register. The loop starts with storing yellow color as loaded earlier at address 40 + y and sets first pixel in the display's color to yellow. iny then increments the index at y register and increments it by 1 and this loop keeps going until Y reaches number FF as it can range from 00 to FF and once it hits that it returns to be 00 and exits the loop. Since this also marks ends of first page it is now essential to increment page so we can fill in next page and so on until it reaches 06 which marks last page. Instruction inc $41 which hold 02, increments it by 1, making it 03 and reaches the next page. We then create a check to stop incrementing pages as we hit the last one, so ldx $41 pulls which page we are on and sort of remembers it. cpx #$06 checks if the last remembered result is number 06, if so it exits the program, otherwise keeps branching it to loop created earlier to fill in individual pages. And in this way whole of the display is filled with yellow color.

No comments:

Post a Comment