Purpose of this ebook Background history with computers Passion for programming My experience with the Commodore 64

Size: px
Start display at page:

Download "Purpose of this ebook Background history with computers Passion for programming My experience with the Commodore 64"

Transcription

1

2 Table of Contents Introduction: About the author Purpose of this ebook Background history with computers Passion for programming My experience with the Commodore 64 Chapter 1: Memory Where in memory to write your game The difference between page 0 and other memory addresses The accumulator Understanding high and low bytes Some important memory locations Understanding high and low byte loops Chapter 2: Graphics ASCII graphics Screen color memory Hi-resolution graphics Commodore 64 sprites Game sprites Loading the game sprites in memory Moving the sprites Moving a sprite in Assembly language

3 Finding the MSB (Most Significant Bit) Sprite passed beyond 255 th position What is multicolor? Understanding character sets Chapter 3: Animation Animating ASCII characters Animating sprites Chapter 4: Joystick (device) What is a joystick? How to read joystick values Moving a sprite with a joystick Chapter 5: From Basic to Assembly Language Basic vs. Assembly Language (speed advantage) Converting Basic code into assembly language Understanding PEEKs and POKEs Converting DATA statements into machine language Opcodes Chapter 6: Getting started with Assembly language Simple addressing Absolute addresses Direct/indirect addresses Understanding labels Chapter 7: Understanding accumulator commands

4 LDA (Load the Accumulator) STA (Store the Accumulator) PLA (Pull from the Accumulator) Chapter 8: Loops/Branches (X/Y index registers) FOR NEXT vs. Assembly language loops What is LDY, LDX? What is INC, DEC? What is BEQ, BNE, BCS, BCC? Creating delay loops Chapter 9: Conditions Difference between Basic IF and Assembly language IF What is CMP? What is CPX? What is CPY? Chapter 10: Math How the Commodore 64 computes Math How the ADD statement works How the SBC statement works How the ASL statement works How the LSR statement works Chapter 11: Bytes What is a byte? How a byte is stored High/Low bytes

5 Using page 6 to store Hi/Low bytes The famous registers: Chapter 12: Jumping in memory (GOTO/GOSUB) Basic vs Assembly language (GOTO vs. JMP) Jumping around in memory o JMP (Jump to memory address) o JSR (Jump to Subroutine, with Return) o Avoid jumping over the 256 byte range Chapter 13: Explanation of the Spaced Out game Overview of the game Breaking it down line by line Chapter 14: Secrets to game design Building room upon room Using flags Character set (redefining) Chapter 15: Where to go from here? The imagination has no limit Going above and beyond

6 Introduction Purpose of this ebook The purpose of this ebook is to show you how my Assembly language game Spaced Out was developed. Please note however this book is not meant to teach you how to write in Assembly language, but will show you how to make the transition from Basic to Assembly language somewhat less complicated. I still highly recommend becoming quite fluent in Basic before writing in assembly language since Basic is easier. I decided to create this ebook due to the large demand from my YouTube subscribers. I figured finally condensing my knowledge into a book should fulfill the purpose of sharing my love of assembly language. The best way to understand assembly language though is to refer to a good book on beginning assembly language. This ebook is not meant to make you an expert on assembly language. Rather it has been created to assist people with a flow process of translating Basic to Assembly language. Background history with computers I got my first real experience when I purchased a Commodore 64 back in I was first convinced about the marvel of this machine when I had a neighbor invite me to his house where he showed me the new computer system his parents got him. At the time, I only owned an Atari 65xe personal computer. I ll never forget the first game he loaded in called Ghostbusters. I was instantly noticed that this machine rivaled the computer I already had. My friend also showed me some Commodore 64 Basic then. I noticed he wasn t a programming due to the constant SYNTAX ERROR messages he created on the screen. However I had already written a few programs on my Atari and was ready to take the plunge into the Commodore 64.

7 Passion for programming My passion with programming originally began on the Atari 65xe system back in 1988, but I was so ready to begin the transition to the Commodore 64 with confidence. I gained a lot of experience in those days by visiting the public library and checking out every programming book I could find from Compute!s books, magazines, and many random books showing simple Commodore 64 programs. My experience with the Commodore 64 The experience I have developing on the Commodore 64 is largely due to the time I spent programming my Atari 65xe system. I had already a firm grasp on Basic at the time and later taught myself assembly language on the Atari computer. It wasn t long after that when I purchased the C64 Assembler diskette and began writing my first Commodore 64 assembly language programs. This lesson will also introduce you to some of the basics of game design. It is my sincere hope and desire that this ebook will help you ascend your knowledge of the Commodore 64 and soon have you developing your next greatest arcade hit! I wish you the best.

8 Chapter 1: Memory Where in memory to write your game Knowing how memory is organized on your Commodore 64 will help you decide the best place to store your program. Memory on the Commodore 64 can be thought of as bookshelves of how it is arranged. The bookcase can be referred to as the Accumulator and the books are the memory locations. Each of the books represents a different memory locations starting at 0 and ending at The difference between page 0 and other memory addresses Page Zero consists of 256 memory locations from 0 through 255. Each location also stores 255 bytes. A byte is consisted of 8 digits that fit into each memory location. Individual bytes perform their own separate processing for example memory location 203 is used to check which key is being pressed. When read into memory it scans the keyboard looking to see which key is held down. Example: 10 VL=PEEK(203) 20 PRINT VL 30 GOTO 10 Memory locations contain the Microprocessor Stack area which is called Page 2. Page 3 is stored through locations range from Then there is memory from known as the video screen memory. The Basic code occupies memory from The character ROM image for the VICP II Chip is in locations Basic s ROM is contained in locations There is a 4k (4 thousand) block of memory held in locations This is where a lot of the real action in game design relies upon to produce colors,

9 sprites, etc. The system kernel ROM uses 8,000 memory locations to keep track of input and output operations found in I have discovered that a safer area of memory when using the C64 Assembler is found at This area is where Basic normally resides. It also far enough away from the character set and prevents having to move things around. Page 0 uses memory locations from These can be used to move memory around creating short loops, set flags, and many for many other things. I used these to clear a section of sprite memory in my Spaced Out game demo. The advantage to using page 0 locations is that there is nothing going on in the accumulator with these registers that will affect your source code. They have been used countless times by programmers to store high and low memory addresses. The accumulator There is a busy section in your Commodore 64 known as the Accumulator. The Compute! book Machine language for Beginners uses an example of a post office that has to deliver mail to 65,536 customers. These customers are referred to as memory locations (or addresses). Each of these houses have special uses such as timers, input/output, sprites, graphics, storing your Basic program, managing interrupts, etc. Some houses don t receive mail since mail doesn t deliver there. That is an example of ROM( Read Only Memory), which basically means you can t write a value there. Understanding high and low bytes Your computer is not only made up of tons of memory locations (a.k.a registers), but it also uses math to calculate moving memory beyond a 256 byte limit. This is because bytes can only access 256 bytes at a time. Here is an example taken from the Spaced Out game CLRMEM 4980 LDA #64 ;(8 *256)=2048+(64) = STA 251

10 5000 LDA # STA LDA # LDX # DY LDY # DS STA (251), Y 5060 INY 5070 BNE DS 5080 INC DEX 5100 BNE DY 5110 RTS Pay special attention to the comment at line It says (8 *256)=2048+(64) = This is showing you how the accumulator calculates a memory location beyond a 256 byte range. It is broken down like this: 4980 LDA #64 ;low byte (64) 4990 STA 251 ;stored in page 0 location LDA #8 ;high byte (8) 5010 STA 252 ;stored in page 0 location 252 So the 251 will store the low bytes and the 252 is used to access the next highest byte. This is also known as zero page addressing. Now we use 256 multiplied by the high byte and return that result which is Then the accumulator simply

11 adds the low byte of 64. Just think of your basic math class and remember to Please Excuse my dear aunt Sally. So literally speaking that means that math is calculating using Parenthesis, Exponents, Multiplication, Division, Adding, and Subtraction (PEMDAS). The key here is to remember that the parenthesis or () are computed first. Then the calculation resumes using the remaining operators. Some important memory locations Some of the most important memory locations found in my game demo are (sprite data pointers), (sprite positions), (Most Significant Bits for sprites 0-7), (Sprite enable), (sprites 0-7 vertical size), (sprite multicolor), (sprites 0-7 horizontal size), (sprite collisions), (sprite foreground collisions), (border/background colors), (sprite multicolor registers), (sprite colors), (sound), etc. Understanding high and low byte loops The rest explained Pay attention to the rest of the code below. I will explain how it works LDA # LDX # DY LDY # DS STA (251), Y 5060 INY 5070 BNE DS 5080 INC DEX 5100 BNE DY

12 The first line is used to store a 0 in the accumulator. Then a loop is created to address 6 pages using LDX #6. This means to start the X register at the value of 6. The next line starts the Y register at 0. Keep in mind that the X and Y register count up to 255 bytes and then flip back to zero. The next line STA (251), Y begins the processing of storing 0 s starting at memory location So the accumulator now looks like this: Memory location value X reg Y reg (count up to 255 or Y= Y + 1 or INY) Remember at this point that the LDY #0 is using INY (increment the Y register) to count as Y = Y + 1:0020IF Y>255 THEN Y=0. The BNE (Branch Not Equal) will allow the Y register to count in a loop until it reaches 255. Once this finishes the next lines are executed: 5080 INC DEX 5100 BNE DY We have now incremented the value found in memory location 252. Remember that we originally used LDA #64 STA 251. So the line INC 252 will now increase the value found there by 1 byte, which means it will contain a 65. Just take 64+1 = 65. The next instruction says DEX (Decrement the X register). So originally the X register was 6 (LDX #6). Now it will contain a 5. The BNE DY will jump all the way back to the line that shows 5040 DY LDY #0 to zero out the Y register once more.

13 We do this since after 256 bytes have incremented (Y = Y +1 example), we have flipped to the next highest byte at location = To get to that byte we have to flip the Y back to zero. Here s the calculation for that: = So the next byte after 256 is We flip the Y back to zero to address the next 256 pages in memory. I realize this is not easy to grasp. Please understand that if you get this you are now on your way to writing advanced assembly language programs. Here is an example. Memory location value X reg Y reg (count down from 4 or X= X - 1 or DEX) = = LDX #3 until we get to the last part LDX #0. Please note I have not tested these values for accuracy so I may be off on the math, but I can nearly guarantee you that the processing is on key.

14 I would suggest writing out the rest if you can so you can grasp it even further. The rewards will be you will soon learn how to copy memory and move it around. This is common in memory relocation and when moving ROM (Read Only Memory) to RAM (Random Access Memory)

15 Chapter 2: Graphics ASCII graphics How graphics work on your Commodore 64. Many Commodore 64 keyboard characters can often be seen embedded at the side of each key. These are known as ASCII (American Standard for Information Interchange) and contain characters from (or a grand total of 256 characters). Screen color memory Your Commodore 64 also utilizes memory to set color points for each character placed in memory locations This is actually known as Color RAM. It can display any ASCII character in 16 different foreground colors (which includes black). Here is an example: POKE 1024,65: POKE 55296, 2 This will plot the A alphabetic character to the top left of your screen and fill it with a red color. Try changing the 65 to another number to see what you get. Then change the color. Here is a list of what each color stored currently in memory location above shows: 0 = Black 1 = White 2 = Red 3 = Cyan 4 = Purple 5 = Green

16 6 = Blue 7 = Yellow 8 = Orange 9 = Brown 10 = Light Red 11 = Dark Gray 12 = Medium Gray 13 = Light Green 14 = Light Blue 15 = Light Gray

17 ASCII characters can be placed side by side to create graphic designs. The Commodore 64 is popular for creating software that cleverly utilizes these characters by lining them up side by side to create a whole picture. There was a Christmas demo to promote the Commodore 64 that used a few sprites and all ASCII characters to create an impressive scene. It used sprite animation to fly Santa across the sky, raster interrupts to create an amazing blizzard, and the ASCII characters made up the city. The amazing thing also is that this demo was written in assembly language. Now you can see what is possible once you learn how to write your own programs. High-resolution graphics Creating high resolution graphics (bitmap mode) on your Commodore 64 though is a little more complex. A bitmap mode is 320 pixels across by 200 pixels high. Memory location must be set to 5 to enable this mode (POKE 53265, PEEK(53265). It can occupy up to 8192 bytes on the screen. Each byte uses four bits that can be set to its own color. The only drawback is that using a bitmap graphics mode can really put a drain on your computer s memory since it takes up

18 so much space. For this example, I will not go into any more detail since my game demo does not utilize bitmap modes. Commodore 64 sprites In the game Spaced Out, I used several sprite images to reproduce the Pitfall Harry character and several images to create the phaser fire. The Commodore 64 system can display up to 7 sprites. Anything beyond these requires using raster interrupts. The sprite characters contain a width of 24 dots in length by 21 dots in height. Each sprite shape is created from 63 bytes of data. To activate a sprite that has been created the system must first enable the sprite and point to the memory address using locations to reference it. Here s a chart to understand this on a more logical level. Sprites can each also contain up to 16 colors individually. Multicolor can be activated to blend colors within the pixels. Sprite location Sprite # Sprite Horz X Sprite Horz Y Color

19 Game sprites Back in the 80s a smash hit Activision game called Pitfall II was developed by David Crane. It used some pretty fascinating sprites. I was pretty impressed by the animation of the Pitfall Harry character that I decided to look up the bytes and implemented it into my game demo. Here is one of the character graphics in that game (not mine). Rather this is used as an example so you can see how sprites are stored in memory. You can also visit my web page here to learn more: It is probably hard to see here in this screenshot, but this sprite contains up to 64 dots (0-63). The asterisks represent the bits that are turned on in the area of memory so we can see the character. Now I will show you step by step how my source code created the sprites you see in the game demo at

20 Loading the game sprites in memory Here is the source code to load the sprites into memory. Now I used locations I was able to alter the Sprite Data Pointer to set a reference to where I copied them in memory. This was necessary to avoid overwriting the character set I created. Code example: 1270 LDX # DWN1 LDA CHAR1, X 1290 STA 2112, X 1300 LDA CHAR2, X 1310 STA 2176, X 1320 LDA CHAR3, X 1330 STA 2240, X 1340 LDA CHAR4, X 1350 STA 2304, X 1360 LDA CHAR5, X 1370 STA 2368, X 1380 LDA CHAR6, X 1390 STA 2432, X 1400 LDA CHAR7, X 1410 STA 2496, X 1420 LDA CHAR8, X 1430 STA 2560, X

21 1440 LDA CHAR9, X 1450 STA 2624, X 1460 LDA CHAR10, X 1470 LDA 2688, X 1480 LDA MISSL, X 1490 STA 2752, X 1500 LDA MISSL2, X 1510 STA 2816, X 1520 LDA PHASRT, X 1530 STA 2880, X 1540 LDA PHASLT, X 1550 STA 2944, X 1560 DEX 1570 BEN DWN1 Now examine the first few lines LDX # DWN1 LDA CHAR1, X 1290 STA 2112, X This sets the X register to 62 since we will be copying bytes of data from The next line DWN1 LDA CHAR1, X is known as Loading the immediate value. The

22 CHAR1, X is used as a vector to point to a memory location that contains the data found in the label called CHAR1. The bytes are where the sprite data is contained at. Any bit other than a 0 means that sprite area is on. The STA 2112, X will store the sprite in memory so it can be seen later once it is enabled. The sprite is also divided into 3 layers containing 8 bytes each. I have divided this for clarity as seen below. Layer 1 Layer 2 Layer 3 CHAR1.BYTE 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0 Moving the sprites Each sprite can move in either a horizontal (left to right) or vertical direction (up to down). Because of the sprite width of 3 across (8 x 8 x 8) = 24, the sprite can have a walking distance from pixels across the screen horizontally. Look at the simple Basic statement below which moves the sprite from 0 to 255 pixel positions. In my game example the sprite can only move up or down between 170 and 230 pixels. Look at the example below.

23 10 FOR X=0 TO 255: POKE 53248, X: NEXT Moving a sprite in Assembly language Here is an example of how the above code might look when converted to Assembly language. MV LDA SPX STA ;POKE 53248,SPX INC SPX ;SPX = SPX + 1 LDA SPX CMP #255 BCC MV ;IF SPX>=255 THEN GOTO MV SPX.BYTE 0 This example will look at the vector in SPX, which is zero. Then it will load that value of 0 into the accumulator (LDA #0). It will then store the sprite s horizontal position in register Then the statement INC SPX will increase the value found there by 1 (SPX = SPX + 1). After this the register is checked with LDA SPX to see the value found there as it is changed. Now it will contain a 2. Next the CMP #255 statement reads Compare the value to see if it is a 255. After this the final instruction of BCC MV reads Branch Carry Clear back to MV. So if the sprite has not yet moved 255 bytes (it is less than 255) then the program will go back to label MV and keep executing the code there (known as a loop). Once the sprite reaches position 255, the code will end. Look at the table below for further clarification.

24 SPX address sprite horiz X (53248) condition Notice that the values of SPX and are changing, but the condition remains the same. A condition value never changes unless you are referencing absolute memory (CMP SPX). The SPX location is changing each time as is location Finding the MSB (Most Significant Bit) When a sprite tries to move to the right more than 255 pixel positions it will reset the accumulator and flip the sprite back to position 0. To continue the sprite smoothly across the screen, we need to access memory location to alter the flag in the accumulator. This will then allow the sprite to proceed through all 512 pixel possible locations on the screen. Examine the code below RGT ;RIGHT ANIMATION 2920 LDA # STA FACE ;FACE= ; 2950 LDA FLAG ;FACING DIRECTION 2960 CMP # BEQ CHKF ;IF FLAG=1 THEN GOTO CHKF 2980 LDA X1 ;IF X1 >=255 THEN GOTO FLIP 2990 CMP #255

25 3000 BCS FLIP IF X1>=255 THEN GOTO FLIP 3010 STA SPRX ;POKE 53248, X JSR PAUSE 3030 JMP OVR 3040 CHKF LDA X CMP # BCS FLIP ;IF X1>=84 THEN GOTO FLIP 3070 STA SPRX ;POKE 53248, X JSR PAUSE 3090 OVR INC PNT ;PNT = PNT LDA PNT 3110 STA PNT 3120 STA SPRPT ;POKE 2040, PNT 3130 LDA PNT 3140 CMP # BCS RSETPT ;IF PNT>=37 THEN GOTO RSETPT 3160 INC X1 ;X1 = X JMP MOVE This code controls the right movement of the sprite. The sprite position is checked to see if it has traveled more than 255 pixels. Look at this line.

26 2980 LDA X CMP # BCS FLIP ;IF X1>255 THEN GOTO FLIP If the sprite has passed beyond 255 pixels then the code will jump to the label called FLIP. Below are examples of Basic and then my assembly language example. 20 X = X IF X > 255 THEN POKE 53264, 1: POKE 53248, 0: FLAG=1 40 IF FLAG=1 AND X<0 THEN POKE 53264, 0: POKE 53248, FLIP 3330 LDA FLAG 3340 CMP # BEQ FXFL ;IF FLAG=1 THEN GOTO FXFL 3360 LDA #0 ;POKE 53248, STA X1 ;X1 = LDA X STA ;POKE 53264, X LDA # STA FLAG ;FLAG= STA FLAG2 ;FLAG2= STA SPRX ;POKE 53248,1

27 3440 JMP JMU 3450 FXFL 3460 JSR RNGCK LDA # STA FLAG ;FLAG= STA FLAG2 ;FLAG2= LDA # STA X1 ;X1= STA SPRX ;POKE 53248, JMU 3550 JMP MOVE Sprite passed beyond 255 th position So here the FLAG is checked to see if we have the MSB set and will jump to label FXFL. If we have already passed the 255 th position then the X1=0 and POKE 53264, 1 will move the sprite to the next horizontal position. Then the variable X1 starts at zero again and increments until we reach the edge of the screen. Finally we get FLAG = 1 and FLAG2 =1 to show we are now using the MSB of location The JMP JMU just keeps the game going back to the main loop. What is multicolor? Hidden deep inside of memory location are the Sprite Multicolor Registers. When you activate the bits stored here you alter pixels colors inside a sprite design. These bits control a double wide pixel of the sprite display. The width of the sprite is reduced to only 12 pixels wide to obtain newer colors. These are known as bit pairs. According to Mapping the Commodore 64 these bit pairs extract their display from the following memory locations:

28 00 Background Color Register 0 01 Sprite Multicolor Register 0 (53285) 10 Sprite Color Registers (53287) 11 Sprite Multicolor Register 1 (53286) Any of the Commodore 64 s seven sprites can contain up to three foreground colors. Look at this example taken from my channel. Here you can see that the sprite is made up of 4 colors. However by utilizing the proper bit pairs you can create colors side by side. Understanding character sets The Commodore 64 system already contains its own character set deep within ROM. If you press the Commodore key and press a key you will see an example of these characters. These are also a part of the ASCII character set. The character set contains up to 256 characters (0-255).

29 Redefining the character set Many of the famous old school Commodore 64 games use what is known as a redefined character set. This involves simply altering the characters to change the pixels within to something rather than the intended design. I have changed the Commodore 64 character set to create the fancy space ship detail in the game Spaced Out. You can see an example below. It is a time consuming processing, but offers some nice eye candy when you take the time to build a good, new character set. How to build your own character set A character set can be redefined by building a simple chart of 8 x 8 on graph paper. Each position you fill in will merge together to form a picture. Look at the example below ####### ####### ####### ####### ####### ####### ####### ####### ####### ####### ####### ####### ####### ####### ###### ####### ####### ####### #######

30 Calculating the rows I realize the above example is a silly graphic, but it will be used to show how to build your very first graphic character. Pay attention to the numbers at the top that show 128, 64, 32, 16, 8, 4, 2, 1. These will be used to calculate the bytes within the image to create the character. The rows are calculated from left to right. Look at row 1 (below the numbers). There are no squares filled in so the first row with have a 0 (zero). Look at row 2. The filled in areas are 64, 32, 4, 2. So we simply add these together to get the result: = 102 Look at row 3. The filled in areas are 64, 32, 4, 2. So we simply add these together to get the result: = 102 Look at row 4. The filled in areas are 128, 32, 16, 8, 4. So we simply add these together to get the result: = 188 Look at row 5: The filled in areas are 16, 8. So we simply add these together to get the result: = 24 Look at row 6: The filled in areas are 16, 8. So we simply add these together to get the result: = 24 Look at row 7: The filled in areas are 16, 8. So we simply add these together to get the result: = 24 Look at row 8. There are no squares filled in so the last row with have a 0 (zero).

31 Sum these together are here are the results: Row bytes result = = = = = = = = 0 Basic example to transfer a character set from ROM to RAM Here is a simple example in my Commodore 64: Basic/Assembly games (91-93) that redefined a character set to produce a platform example. 10 CM=12288: CX=53248: GOSUB POKE 53272, (PEEK (53272) AND 240) OR FOR I =12504 TO *6: READ N: POKE I, N: NEXT 40 END 390 PRINT CHR$(147) 400 POKE 781, 10: POKE 782, 6: SYS 65520: PRINT PLEASE WAIT TRANSFERRING SET 410 POKE 56344, PEEK (56344) AND 254

32 420 POKE 1, PEEK (1) AND FOR I=0 TO 1023: POKE CM+ I, PEEK (CX + I): NEXT 440 POKE 1, PEEK (1) OR POKE 56334, PEEK (56334) OR 1: RETURN 460 DATA 0, 0, 0, 0, 0, 0, 0, DATA 253,219,239,255,127,237,233, DATA 65, 126, 66, 66, 126, 66, 66, DATA 0, 42, 28, 62, 28, 42,0, DATA 127,255,239,253,191,247,237, DATA 0, 0, 0, 0, 0, 0, 0, DATA 24, 18, 223, 12, 253, 217, 191, 251 By simply changing one of the DATA statements above to your own design you are on your way to creating your very first redefined character. Assembly language example to transfer a character set 1190 CSET=251 ; get low-byte 1200 LOOKM=253 ; get low-byte 5150 CHSET 5160 ; 5170 LDA # STA ; POKE 56334, LDA #51

33 5200 STA 1 ; POKE 1, LDA # STA CSET ; CSET = LDA # STA CSET+1 ; CSET + 1 = LDA # STA LOOKM ; LOOKM = LDA # STA LOOKM+1 ; LOOKM+1 = LDX # RDY LDY # STV LDA (LOOKM), Y 5320 STA (CSET), Y 5330 INY 5340 BNE STU 5350 INC LOOKM+1 ; PEEK(254) = PEEK(254) + 1 increment high-byte 5360 INC CSET+1 ; PEEK(252) = PEEK(252) + 1 increment high-byte 5370 DEX 5380 BNE RDY 5390 ; 5400 LDA # STA 1 ; POKE 1, 55

34 5420 LDA # STA ; POKE 56334, ; 5450 LDA # STA ; POKE 53272, RTS

35 Chapter 3: Animation Animating ASCII characters Animation of ASCII characters in Basic is done by poking a screen character in screen memory, erasing it, incrementing to the next screen address, and poking in it the new position. It is also faster to animate by POKEing a character rather than just positioning with statements like POKE 214,2: PRINT: PRINT A The below example will count from 1 to 40 in the first loop. The second loop with wait for 50 clock cycles before continuing with the NEXT statement. Then the POKE I, 32 will send a space character to the screen position on your C64 screen to erase it. After this the final NEXT will jump back to the first I loop and now I will be a 1. It continues until the loops are done. Look at the example below the code for more clarity. Here is a simple example: 10 FOR X=0 TO 40: POKE 1024+X, FOR DELAY=1 TO 50: NEXT 30 POKE 1024+X, 32 : REM erase the character 40 NEXT A simplified step by step example: 10 X=1 : REM The first time the loop begins at 1. POKE X, 65 : REM Show the letter A on the screen DELAY = 1, 2, 3, 4, : REM COUNT UP TO 50

36 POKE X, 32 :REM Show a space in place of the letter A X = 2 : REM Increase the first loop now to a 2. GO BACK TO LINE 10 : REM Repeat until I is 40. I have used the above example to simulate a simple process of animation. In the game demo Spaced Out I use sprite animation. However I wanted to start with a simple example to explain how movement works. Animating sprites First I will show a simple BASIC example of sprite movement. Then I will demonstrate how this works in the source code. An example I showed earlier involved moving a sprite across the screen. Keep in mind that a sprite does not have to be erased like an ASCII character. It can easily be moved across the screen without affecting any other ASCII text remaining. Here is that example again which moves a sprite horizontally to the right across the screen. 10 FOR X=0 TO 255: POKE 53248, X: NEXT Here is an example of moving a sprite vertically down the screen. 10 FOR Y=0 TO 255: POKE 53249, Y: NEXT Now in these two examples you have only witnessed animating in moving a single shape across the screen. However the C64 system is clever and you can add individual animation frames for your sprite as it moves. Animating frames I only touched on this briefly earlier, but locations hold the sprite shape data that is used in the Spaced Out example to reproduce varying frame drawings as the sprite is moved left or right. All that is required is to be sure that

37 these frames are loaded into memory and displayed during the movement. Look at the assembly language example below OVR2 INC PNT2 ; PNT2 = PNT LDA PNT STA PNT STA SPRPT ; POKE 2040, PNT LDA PNT CMP # BCS RSETP2 ; IF PNT2 >=42 THEN GOTO RSETP DEC X1 ; X1 = X1-1: POKE 53248, X JMP MOVE 3190 RSETP LDA # STA PNT STA 2040 ; POKE 2040, JMP MOVE The code above sets up a variable called PNT2 to increment from 32 to 48. This properly accesses the sprite frames stored there. Each time PNT2 increases by 1 value a new frame of animation is seen. Once PNT2 is equal to 42 or above then the program will jump to the label called RSETP2. Then a POKE 2040, 32 will execute and the variable (memory address) PNT2 will be equal to 32 again. This allows the frames to flip over again starting at 32. The animation of the right movement is identical, but uses a new label called PNT. This allows the sprite to

38 keep track of the currently shown frames in location 2040 for the sprite during the left and right movement.

39 Chapter 4: Joystick (device) What is a joystick? A joystick is handheld and contains an attached stick that can be move in several lateral directions. It also includes a fire button that was popularized by earlier Atari 2600 cartridge games. A joystick is plugged into one of two different data ports on the system. On the Commodore 64 the CIA (Complex Interface Adapter) chip receives communications from the 6510 microprocessor to control joysticks, paddles, peripheral input and output devices. Receiving commands from the ports involves writing a simple Basic program to read the bits arriving there when the device is moved in one of 6 directions. Here is such an example. 10 JY = PEEK (56320) : REM Scan Data Port 1 20 PRINT JY : REM Show the value found there 30 GOTO 10 : REM Repeat the loop Now as the joystick is moved, the ports with interrupt the processor to get a return value. Each movement of the joystick could be used to maneuver a spaceship in all directions resulting in smooth control. When you plug in a second joystick then port is read. Fire button When you press the single button found on a joystick an interrupt is received to the ports to signal an action has taken place. A fire button gets its name from the coin operated arcades that were popular in the 80s, which was used to initiate a missile traveling towards a naval carrier or a laser honed in on an alien squadron.

40 Here is an example to read the fire button. When the joystick is plugged in the values can be read. Move the joystick and press the fire button to watch them change. The below example reads from memory location FI = PEEK (56320) 20 PRINT FI 30 GOTO 10

41 How the game Spaced Out uses the joystick Pay careful attention to the source code in the game and you will notice the port values (123, 119, 125, 126, 111). Use the diagram above to see which position the joystick has been moved on. Hopefully this will guide you in understanding how the 6502 processor uses accumulator values to read the joystick at memory location MOVE 2400 ; 2410 LDA JOY ; JY=PEEK (56320) 2420 CMP #123 ; IF PEEK (56320) =123 THEN GOTO LEFT 2430 BEQ LEFT ; IF JY=123 THEN GOTO LEFT 2440 CMP # BEQ RGT ; JOYSTICK PUSHED RIGHT 2460 CMP # BEQ MVDN ; JOYSTICK PUSHED DOWN 2480 CMP # BEQ MVUP ; JOYSTICK PUSHED UP This is a label called MOVE that controls the joystick in the game. The LDA JOY is reading the port at memory location The next instruction CMP #123 is checking that the value was moved to the left (see above diagram). Finally the first branch (jump) will GOTO the label called LEFT to signal that the user has pressed the joystick in that direction. The next CMP (Compares) for 119, 125, 126 are reading the remaining positions. Reading the fire button during the game

42 The code below reads the fire button, which causes the sprite missile lasers to travel across the screen. It will compare the value found in JOY (location 56320) to see if it returned a 111 to indicate that the fire button was pressed down. Then the code will jump to the label called SHOT CMP # BEQ SHOT ; IF PEEK (56320) = 111 THEN GOTO SHOT Shooting the missiles when the fire button is pressed The code below shows how the missiles were programmed into the game. Once the user has pressed the fire button (which again sets memory location = 111) then the game jumps to the label called SHOT. This is probably bad programming, but I used a label to reference another label. So the game then jumps to the label called SHOOT. This game animates the sprite lasers in the left or right direction when the player presses the fire button and is moving in that direction. SHOT JMP SHOOT

43 Chapter 5: From Basic to Assembly language Basic vs. Assembly language (speed advantage) This section has been created to enhance your knowledge of how assembly language and Basic programming go hand in hand. It is recommended to have a least some experience with Basic to follow along. I saw this example in a C64 book years ago, but saw a lack of connecting Basic to Assembly language so a beginner could keep up. Understanding the object code The PEEK command is used to read values found in memory locations. When building a machine language program, there are specific values (numbers) that represent assembly language instructions. I have listed them below for reference. The values you want to pay particular attention to is the column DEC (Decimal). This is what you will see when you PEEK into a Basic memory location. The HX (Hex) shows the hexadecimal. I will not be using hexadecimal in this ebook. The CHAR shows the ASCII value for that machine instruction. Finally the columns opc (Opcode) and ALform make up the assembly language instruction for the high and low byte addressing.

44 It may look like a lot, but I promise you that once you get used to developing in Assembly language you will see how Basic compliments it. As a matter of fact,

45 Basic is actually known as an interpreted language which is basically a bunch of assembly language instructions that check Basic for errors, scan statements to make sure a command (such as PRINT) examples in a lookup table, and sets execution of the program based on the computer s clock speed. It also does a lot more, but for brevity I have limited the other options to keep this example simple. LDA (Load the Accumulator) This is one of the first Assembly language instructions you will learn. It simple means to check the value found in the accumulator to see what exists there. In Basic this is interpreted to mean PEEK into a memory location to see what is found there. Most of the smaller assembly language programs use an addressing mode called absolute. Here is an example to read a joystick port (demonstrated in Chapter 4). LDA ; Read the value in memory location There is another addressing mode called immediate. It means to take a number and place it into the accumulator. Think of this as placing a book marker inside a book that is stored in a bookcase that has not been closed yet. Here is an example. LDA #255 The accumulator now contains the number 255. The # represents immediate to signal that we are looking for a number and not a memory location. STA (Store the accumulator) Let s move onto another instruction that will allow us to save a value into the accumulator. If you are visual like me then imagine that same book that has the book marker contained in it and then somebody closes the book. Now it is safely inside the book. Here is an example to change the screen border to red. In Basic this looks like POKE 53280, 2

46 LDA #2 ; Load the accumulator with immediate value of 2 STA ; Store the 2 into memory location 53280

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture) COSC 243 Instruction Sets And Addressing Modes 1 Overview This Lecture Source Chapters 12 & 13 (10 th editition) Textbook uses x86 and ARM (we use 6502) Next 2 Lectures Assembly language programming 2

More information

AN INTRODUCTION TO SCRATCH (2) PROGRAMMING

AN INTRODUCTION TO SCRATCH (2) PROGRAMMING AN INTRODUCTION TO SCRATCH (2) PROGRAMMING Document Version 2 (04/10/2014) INTRODUCTION SCRATCH is a visual programming environment and language. It was launched by the MIT Media Lab in 2007 in an effort

More information

The 6502 Instruction Set

The 6502 Instruction Set The 6502 Instruction Set Load and Store Group LDA Load Accumulator N,Z LDX Load X Register N,Z LDY Load Y Register N,Z STA Store Accumulator STX Store X Register STY Store Y Register Arithmetic Group ADC

More information

COMPUTE! ISSUE 36 / MAY 1983 / PAGE 244

COMPUTE! ISSUE 36 / MAY 1983 / PAGE 244 Versatile Data Acquisition with VIC Doug Homer and Stan Klein COMPUTE! ISSUE 36 / MAY 1983 / PAGE 244 This simple method of adjusting the VIC's internal jiffy dock can slow it down to match your timing

More information

Microcontroller Systems

Microcontroller Systems µcontroller systems 1 / 43 Microcontroller Systems Engineering Science 2nd year A2 Lectures Prof David Murray david.murray@eng.ox.ac.uk www.robots.ox.ac.uk/ dwm/courses/2co Michaelmas 2014 µcontroller

More information

Lecture #2 January 30, 2004 The 6502 Architecture

Lecture #2 January 30, 2004 The 6502 Architecture Lecture #2 January 30, 2004 The 6502 Architecture In order to understand the more modern computer architectures, it is helpful to examine an older but quite successful processor architecture, the MOS-6502.

More information

Activity 1 Creating a simple gradebook

Activity 1 Creating a simple gradebook Activity 1 Creating a simple gradebook 1 Launch Excel to start a new spreadsheet a. Click on the Excel icon to start a new workbook, either from the start menu, Office Toolbar, or an Excel icon on the

More information

MAT 003 Brian Killough s Instructor Notes Saint Leo University

MAT 003 Brian Killough s Instructor Notes Saint Leo University MAT 003 Brian Killough s Instructor Notes Saint Leo University Success in online courses requires self-motivation and discipline. It is anticipated that students will read the textbook and complete sample

More information

Chapter 1 Operations With Numbers

Chapter 1 Operations With Numbers Chapter 1 Operations With Numbers Part I Negative Numbers You may already know what negative numbers are, but even if you don t, then you have probably seen them several times over the past few days. If

More information

EEN118 LAB FOUR. h = v t ½ g t 2

EEN118 LAB FOUR. h = v t ½ g t 2 EEN118 LAB FOUR In this lab you will be performing a simulation of a physical system, shooting a projectile from a cannon and working out where it will land. Although this is not a very complicated physical

More information

In this lesson, you ll learn how to:

In this lesson, you ll learn how to: LESSON 5: ADVANCED DRAWING TECHNIQUES OBJECTIVES In this lesson, you ll learn how to: apply gradient fills modify graphics by smoothing, straightening, and optimizing understand the difference between

More information

Meet the Cast. The Cosmic Defenders: Gobo, Fabu, and Pele The Cosmic Defenders are transdimensional

Meet the Cast. The Cosmic Defenders: Gobo, Fabu, and Pele The Cosmic Defenders are transdimensional Meet the Cast Mitch A computer science student who loves to make cool programs, he s passionate about movies and art, too! Mitch is an all-around good guy. The Cosmic Defenders: Gobo, Fabu, and Pele The

More information

JBit E1 (1) Subroutines. Preface. Usage. Tables. Program Layout

JBit E1 (1) Subroutines. Preface. Usage. Tables. Program Layout JBit E1 (1) Preface, Usage, Program Layout, Subroutines, Tables Preface JBit E1 (1) The E1 series will show you how to write a complete application with JBit. While the application is trivial by today

More information

Creating Breakout - Part 2

Creating Breakout - Part 2 Creating Breakout - Part 2 Adapted from Basic Projects: Game Maker by David Waller So the game works, it is a functioning game. It s not very challenging though, and it could use some more work to make

More information

III. Flags of the Processor Staus Register

III. Flags of the Processor Staus Register III. Flags of the Processor Staus Register INHALT 1. Meaning 2. Application 2.1 Shifts 2.2 Branches 2.3 Addition and Subtraction 2.4 Comparisons in magnitude 1. Meaning processor status register Overflow

More information

In this lecture, we will look at how storage (or memory) works with processor in a computer system. This is in preparation for the next lecture, in

In this lecture, we will look at how storage (or memory) works with processor in a computer system. This is in preparation for the next lecture, in In this lecture, we will look at how storage (or memory) works with processor in a computer system. This is in preparation for the next lecture, in which we will examine how a microprocessor actually works

More information

address ALU the operation opcode ACC Acc memory address

address ALU the operation opcode ACC Acc memory address In this lecture, we will look at how storage (or memory) works with processor in a computer system. This is in preparation for the next lecture, in which we will examine how a microprocessor actually works

More information

Practical Course File For

Practical Course File For Practical Course File For Microprocessor (IT 473) B.Tech (IT) IV-SEM Department of IT University Institute of Engineering & Technology Panjab University, Chandigarh Page 1 INTRODUCTION... 4 EXPERIMENT-1:

More information

Example Programs for 6502 Microprocessor Kit

Example Programs for 6502 Microprocessor Kit Example Programs for 6502 Microprocessor Kit 0001 0000 0002 0000 GPIO1.EQU $8000 0003 0000 0004 0000 0005 0200.ORG $200 0006 0200 0007 0200 A5 00 LDA $0 0008 0202 8D 00 80 STA $GPIO1 0009 0205 00 BRK 0010

More information

Platform Games Drawing Sprites & Detecting Collisions

Platform Games Drawing Sprites & Detecting Collisions Platform Games Drawing Sprites & Detecting Collisions Computer Games Development David Cairns Contents Drawing Sprites Collision Detection Animation Loop Introduction 1 Background Image - Parallax Scrolling

More information

A Technical Overview of Commodore Copy Protection. Glenn Holmer ( ShadowM ) World of Commodore Expo, 12/01/2007

A Technical Overview of Commodore Copy Protection. Glenn Holmer ( ShadowM )   World of Commodore Expo, 12/01/2007 A Technical Overview of Commodore Copy Protection Glenn Holmer ( ShadowM ) www.lyonlabs.org/commodore/c64.html World of Commodore Expo, 12/01/2007 Why Talk About This? These skills were a black art to

More information

Memory Addressing, Binary, and Hexadecimal Review

Memory Addressing, Binary, and Hexadecimal Review C++ By A EXAMPLE Memory Addressing, Binary, and Hexadecimal Review You do not have to understand the concepts in this appendix to become well-versed in C++. You can master C++, however, only if you spend

More information

If Statements, For Loops, Functions

If Statements, For Loops, Functions Fundamentals of Programming If Statements, For Loops, Functions Table of Contents Hello World Types of Variables Integers and Floats String Boolean Relational Operators Lists Conditionals If and Else Statements

More information

Aircraft Combat. A mini game.

Aircraft Combat. A mini game. Aircraft Combat A mini game Yun Miao Siyu Tan soc12ymi@student.lu.se soc12sta@student.lu.se 16/10/2013 ABSTRACT This report documents the development of an aircraft combat game. In this project, the game

More information

The word pixel means a picture element, or if you must a dot on the screen.

The word pixel means a picture element, or if you must a dot on the screen. QL Graphics Dilwyn Jones This is an article for readers who are not used to using high resolution and high colour displays. It doesn t go into too many specifics, just aims to give you a base level of

More information

Converting Between Mixed Numbers & Improper Fractions

Converting Between Mixed Numbers & Improper Fractions 01 Converting Between Mixed Numbers & Improper Fractions A mixed number is a whole number and a fraction: 4 1 2 An improper fraction is a fraction with a larger numerator than denominator: 9 2 You can

More information

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller of 8085 microprocessor 8085 is pronounced as "eighty-eighty-five" microprocessor. It is an 8-bit microprocessor designed by Intel in 1977 using NMOS technology. It has the following configuration 8-bit

More information

Data Representation 1

Data Representation 1 1 Data Representation Outline Binary Numbers Adding Binary Numbers Negative Integers Other Operations with Binary Numbers Floating Point Numbers Character Representation Image Representation Sound Representation

More information

Code Secrets of Wolfenstein 3D IIGS. Eric Shepherd

Code Secrets of Wolfenstein 3D IIGS. Eric Shepherd Code Secrets of Wolfenstein 3D IIGS Eric Shepherd Fast Screen Refresh with PEI Slamming Or, Dirty Tricks with the Direct Page IIGS Features We Can Abuse Super high-resolution graphics shadowing Bank $01

More information

A3 Computer Architecture

A3 Computer Architecture A3 Computer Architecture Engineering Science 3rd year A3 Lectures Prof David Murray david.murray@eng.ox.ac.uk www.robots.ox.ac.uk/ dwm/courses/3co Michaelmas 2000 1 / 1 2: Introduction to the CPU 3A3 Michaelmas

More information

How Computer Mice Work

How Computer Mice Work How Computer Mice Work Inside this Article 1. Introduction to How Computer Mice Work 2. Evolution of the Computer Mouse 3. Inside a Mouse 4. Connecting Computer Mice 5. Optical Mice 6. Optical Mouse Accuracy

More information

Programming the Motorola MC68HC11 Microcontroller

Programming the Motorola MC68HC11 Microcontroller Programming the Motorola MC68HC11 Microcontroller COMMON PROGRAM INSTRUCTIONS WITH EXAMPLES aba Add register B to register A Similar commands are abx aby aba add the value in register B to the value in

More information

Millionaire. Input. Output. Problem limit seconds

Millionaire. Input. Output. Problem limit seconds Millionaire Congratulations! You were selected to take part in the TV game show Who Wants to Be a Millionaire! Like most people, you are somewhat risk-averse, so you might rather take $250,000 than a 50%

More information

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below. Graphing in Excel featuring Excel 2007 1 A spreadsheet can be a powerful tool for analyzing and graphing data, but it works completely differently from the graphing calculator that you re used to. If you

More information

COPYRIGHTED MATERIAL. An Introduction to Computers That Will Actually Help You in Life. Chapter 1. Memory: Not Exactly 0s and 1s. Memory Organization

COPYRIGHTED MATERIAL. An Introduction to Computers That Will Actually Help You in Life. Chapter 1. Memory: Not Exactly 0s and 1s. Memory Organization Chapter 1 An Introduction to Computers That Will Actually Help You in Life Memory: Not Exactly 0s and 1s Memory Organization A Very Simple Computer COPYRIGHTED MATERIAL 2 Chapter 1 An Introduction to Computers

More information

SPRITES Moving Two At the Same Using Game State

SPRITES Moving Two At the Same Using Game State If you recall our collision detection lesson, you ll likely remember that you couldn t move both sprites at the same time unless you hit a movement key for each at exactly the same time. Why was that?

More information

MOS 6502 Architecture

MOS 6502 Architecture MOS 6502 Architecture Lecture 3 Fall 17 1 History Origins lie in the Motorola 6800. Was very expensive for consumers. ($300, or about $1500 in 2017 $s) Chuck Peddle proposes lower-cost, lower-area 6800

More information

19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd

19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd 19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd Will you walk a little faster? said a whiting to a snail, There s a porpoise close behind us, and he s treading

More information

real-time kernel documentation

real-time kernel documentation version 1.1 real-time kernel documentation Introduction This document explains the inner workings of the Helium real-time kernel. It is not meant to be a user s guide. Instead, this document explains overall

More information

EEN118 LAB FOUR. h = v t ½ g t 2

EEN118 LAB FOUR. h = v t ½ g t 2 EEN118 LAB FOUR In this lab you will be performing a simulation of a physical system, shooting a projectile from a cannon and working out where it will land. Although this is not a very complicated physical

More information

To make programs readable and usefull it is wise to use instead of the numbers variables and give that variables the correct numbers

To make programs readable and usefull it is wise to use instead of the numbers variables and give that variables the correct numbers 1 REM ***************************************** 2 REM * HERE FIRST THE SOFT- * 3 REM * SWITCHES / PEEKS AND * 4 REM * POKES USED WITH THE * 5 REM * GAMEPORT THIS BLOCK * 6 REM * MAY BE REMOVED TO KEEP

More information

Learn Ninja-Like Spreadsheet Skills with LESSON 9. Math, Step by Step

Learn Ninja-Like Spreadsheet Skills with LESSON 9. Math, Step by Step EXCELL MASTERY Learn Ninja-Like Spreadsheet Skills with LESSON 9 Doing Math, Step by Step It s Elementary, My Dear Ninja There is a scene in the short story The Crooked Man, where Sherlock Holmes accurately

More information

Objective- Students will be able to use the Order of Operations to evaluate algebraic expressions. Evaluating Algebraic Expressions

Objective- Students will be able to use the Order of Operations to evaluate algebraic expressions. Evaluating Algebraic Expressions Objective- Students will be able to use the Order of Operations to evaluate algebraic expressions. Evaluating Algebraic Expressions Variable is a letter or symbol that represents a number. Variable (algebraic)

More information

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this

More information

Microsoft Excel 2007

Microsoft Excel 2007 Learning computers is Show ezy Microsoft Excel 2007 301 Excel screen, toolbars, views, sheets, and uses for Excel 2005-8 Steve Slisar 2005-8 COPYRIGHT: The copyright for this publication is owned by Steve

More information

Making use of other Applications

Making use of other Applications AppGameKit 2 Collision Using Arrays Making use of other Applications Although we need game software to help makes games for modern devices, we should not exclude the use of other applications to aid the

More information

COMMODORE 64 ASSEMBLY LANGUAGE ARCADE GAME PROGRAMMING

COMMODORE 64 ASSEMBLY LANGUAGE ARCADE GAME PROGRAMMING COMMODORE 64 ASSEMBLY LANGUAGE ARCADE GAME PROGRAMMING This book is dedicated to mypaients. COMMODORE 64 ASSEMBLY LANGUAGE ARCADE GAME PROGRAMMING STEVE BRESS ITABITAB BOOKS Inc. Blue Ridge Summit, PA

More information

MoleMash for App Inventor 2. Getting Started. Introduction. Workshop, S.1

MoleMash for App Inventor 2. Getting Started. Introduction. Workshop, S.1 In the game MoleMash, a mole pops up at random positions on a playing field, and the player scores points by hitting the mole before it jumps away. This tutorial shows how to build MoleMash as an example

More information

Using the stack and the stack pointer

Using the stack and the stack pointer Using the stack and the stack pointer o The Stack and Stack Pointer o The stack is a memory area for temporary storage o The stack pointer points to the last byte in the stack o Some instructions which

More information

Micro-KIM Tutorial. Aart J.C. Bik

Micro-KIM Tutorial. Aart J.C. Bik Micro-KIM Tutorial Aart J.C. Bik http://www.aartbik.com/ 1 Getting Started Perhaps reminiscing the past is a sign of getting older, but I cannot help but look back fondly at the times I learned programming

More information

Using Flash Animation Basics

Using Flash Animation Basics Using Flash Contents Using Flash... 1 Animation Basics... 1 Exercise 1. Creating a Symbol... 2 Exercise 2. Working with Layers... 4 Exercise 3. Using the Timeline... 6 Exercise 4. Previewing an animation...

More information

EEN118 LAB FOUR. h = v t ½ g t 2

EEN118 LAB FOUR. h = v t ½ g t 2 EEN118 LAB FOUR In this lab you will be performing a simulation of a physical system, shooting a projectile from a cannon and working out where it will land. Although this is not a very complicated physical

More information

EXCEL 2003 DISCLAIMER:

EXCEL 2003 DISCLAIMER: EXCEL 2003 DISCLAIMER: This reference guide is meant for experienced Microsoft Excel users. It provides a list of quick tips and shortcuts for familiar features. This guide does NOT replace training or

More information

EEN118 LAB FOUR. h = v t - ½ g t 2

EEN118 LAB FOUR. h = v t - ½ g t 2 EEN118 LAB FOUR In this lab you will be performing a simulation of a physical system, shooting a projectile from a cannon and working out where it will land. Although this is not a very complicated physical

More information

CS 101, Mock Computer Architecture

CS 101, Mock Computer Architecture CS 101, Mock Computer Architecture Computer organization and architecture refers to the actual hardware used to construct the computer, and the way that the hardware operates both physically and logically

More information

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers o How to disassemble an MC9S12 instruction sequence o Binary numbers are a code and represent what the programmer intends for the

More information

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers o How to disassemble an MC9S12 instruction sequence o Binary numbers are a code and represent what the programmer intends for the

More information

Getting Ready. Preschool. for. Fun with Dinosaurs. and. Monsters

Getting Ready. Preschool. for. Fun with Dinosaurs. and. Monsters Getting Ready for Preschool Fun with Dinosaurs and Monsters AND MANY MORE! Thank you so much for downloading my product for your classroom or for at home. Below you can read about how you can use the download.

More information

Recognizing a Function

Recognizing a Function Recognizing a Function LAUNCH (7 MIN) Before Why would someone hire a dog walking service? During Do you know exactly what it would cost to hire Friendly Dog Walking? After How does each service encourage

More information

(Refer Slide Time 00:01:09)

(Refer Slide Time 00:01:09) Computer Organization Part I Prof. S. Raman Department of Computer Science & Engineering Indian Institute of Technology Lecture 3 Introduction to System: Hardware In the previous lecture I said that I

More information

COSC 243. Assembly Language Techniques. Lecture 9. COSC 243 (Computer Architecture)

COSC 243. Assembly Language Techniques. Lecture 9. COSC 243 (Computer Architecture) COSC 243 Assembly Language Techniques 1 Overview This Lecture Source Handouts Next Lectures Memory and Storage Systems 2 Parameter Passing In a high level language we don t worry about the number of parameters

More information

Summer Assignment Glossary

Summer Assignment Glossary Algebra 1.1 Summer Assignment Name: Date: Hour: Directions: Show all work for full credit using a pencil. Circle your final answer. This assignment is due the first day of school. Use the summer assignment

More information

Microprocessor Architecture. mywbut.com 1

Microprocessor Architecture. mywbut.com 1 Microprocessor Architecture mywbut.com 1 Microprocessor Architecture The microprocessor can be programmed to perform functions on given data by writing specific instructions into its memory. The microprocessor

More information

instruction 1 Fri Oct 13 13:05:

instruction 1 Fri Oct 13 13:05: instruction Fri Oct :0:0. Introduction SECTION INSTRUCTION SET This section describes the aressing modes and instruction types.. Aressing Modes The CPU uses eight aressing modes for flexibility in accessing

More information

3Using and Writing. Functions. Understanding Functions 41. In this chapter, I ll explain what functions are and how to use them.

3Using and Writing. Functions. Understanding Functions 41. In this chapter, I ll explain what functions are and how to use them. 3Using and Writing Functions Understanding Functions 41 Using Methods 42 Writing Custom Functions 46 Understanding Modular Functions 49 Making a Function Modular 50 Making a Function Return a Value 59

More information

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7 ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume LECTURE 7 Reading Assignments Reading assignments for this week and next

More information

CHAPTER 1: INTEGERS. Image from CHAPTER 1 CONTENTS

CHAPTER 1: INTEGERS. Image from  CHAPTER 1 CONTENTS CHAPTER 1: INTEGERS Image from www.misterteacher.com CHAPTER 1 CONTENTS 1.1 Introduction to Integers 1. Absolute Value 1. Addition of Integers 1.4 Subtraction of Integers 1.5 Multiplication and Division

More information

Spam. Time: five years from now Place: England

Spam. Time: five years from now Place: England Spam Time: five years from now Place: England Oh no! said Joe Turner. When I go on the computer, all I get is spam email that nobody wants. It s all from people who are trying to sell you things. Email

More information

(Refer Slide Time: 01:25)

(Refer Slide Time: 01:25) Computer Architecture Prof. Anshul Kumar Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture - 32 Memory Hierarchy: Virtual Memory (contd.) We have discussed virtual

More information

Smoother Graphics Taking Control of Painting the Screen

Smoother Graphics Taking Control of Painting the Screen It is very likely that by now you ve tried something that made your game run rather slow. Perhaps you tried to use an image with a transparent background, or had a gazillion objects moving on the window

More information

Interactive Tourist Map

Interactive Tourist Map Adobe Edge Animate Tutorial Mouse Events Interactive Tourist Map Lesson 1 Set up your project This lesson aims to teach you how to: Import images Set up the stage Place and size images Draw shapes Make

More information

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation Course Schedule CS 221 Computer Architecture Week 3: Information Representation (2) Fall 2001 W1 Sep 11- Sep 14 Introduction W2 Sep 18- Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25- Sep

More information

; Once Initialized, monitor character in calls to CN05 ; set carry for input, to be tested CN35 C SEC

; Once Initialized, monitor character in calls to CN05 ; set carry for input, to be tested CN35 C SEC // // Serialcode.s // 256 Byte Prom P8 and 512 Byte PROM P9A (second version) for Apple II Serial Card // P9A differs from P9 by adding RTS/ACK software flow control to output and // by removing batch

More information

EXCEL BASICS: MICROSOFT OFFICE 2010

EXCEL BASICS: MICROSOFT OFFICE 2010 EXCEL BASICS: MICROSOFT OFFICE 2010 GETTING STARTED PAGE 02 Prerequisites What You Will Learn USING MICROSOFT EXCEL PAGE 03 Opening Microsoft Excel Microsoft Excel Features Keyboard Review Pointer Shapes

More information

Clickteam Fusion 2.5 Creating a Debug System - Guide

Clickteam Fusion 2.5 Creating a Debug System - Guide INTRODUCTION In this guide, we will look at how to create your own 'debug' system in Fusion 2.5. Sometimes when you're developing and testing a game, you want to see some of the real-time values of certain

More information

CPU ARCHITECTURE. QUESTION 1 Explain how the width of the data bus and system clock speed affect the performance of a computer system.

CPU ARCHITECTURE. QUESTION 1 Explain how the width of the data bus and system clock speed affect the performance of a computer system. CPU ARCHITECTURE QUESTION 1 Explain how the width of the data bus and system clock speed affect the performance of a computer system. ANSWER 1 Data Bus Width the width of the data bus determines the number

More information

LESSON 2 VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT

LESSON 2 VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT LESSON VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT PROF. JOHN P. BAUGH PROFJPBAUGH@GMAIL.COM PROFJPBAUGH.COM CONTENTS INTRODUCTION... Assumptions.... Variables and Data Types..... Numeric Data Types:

More information

1.1 Data representation

1.1 Data representation 1.1.2 HEXADECIMAL NUMBER SYSTEM The one main disadvantage of binary numbers is that the binary string equivalent of a large decimal base-10 number can be quite long. When working with large digital systems,

More information

A. CPU INSTRUCTION SET SUMMARY

A. CPU INSTRUCTION SET SUMMARY A. CPU INSTRUCTION SET SUMMARY This appendix summarizes the CPU instruction set. Table A-1 is a matrix of CPU instructions and addressing modes arranged by operation code. Table A-2 lists the CPU instruction

More information

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed. Preface Here are my online notes for my Algebra course that I teach here at Lamar University, although I have to admit that it s been years since I last taught this course. At this point in my career I

More information

2.2 THE MARIE Instruction Set Architecture

2.2 THE MARIE Instruction Set Architecture 2.2 THE MARIE Instruction Set Architecture MARIE has a very simple, yet powerful, instruction set. The instruction set architecture (ISA) of a machine specifies the instructions that the computer can perform

More information

EXCEL + POWERPOINT. Analyzing, Visualizing, and Presenting Data-Rich Insights to Any Audience KNACK TRAINING

EXCEL + POWERPOINT. Analyzing, Visualizing, and Presenting Data-Rich Insights to Any Audience KNACK TRAINING EXCEL + POWERPOINT Analyzing, Visualizing, and Presenting Data-Rich Insights to Any Audience KNACK TRAINING KEYBOARD SHORTCUTS NAVIGATION & SELECTION SHORTCUTS 3 EDITING SHORTCUTS 3 SUMMARIES PIVOT TABLES

More information

Lesson 5: Verifying RAMs with the Fluke 9010A Version 1.03

Lesson 5: Verifying RAMs with the Fluke 9010A Version 1.03 Lesson 5: Verifying RAMs with the Fluke 9010A Version 1.03 Random Access Memory: One of the most common failures that occur on arcade PCBS are failures in Random Access Memory (RAM). These failures will

More information

Excel Basics Fall 2016

Excel Basics Fall 2016 If you have never worked with Excel, it can be a little confusing at first. When you open Excel, you are faced with various toolbars and menus and a big, empty grid. So what do you do with it? The great

More information

EXCEL BASICS: MICROSOFT OFFICE 2007

EXCEL BASICS: MICROSOFT OFFICE 2007 EXCEL BASICS: MICROSOFT OFFICE 2007 GETTING STARTED PAGE 02 Prerequisites What You Will Learn USING MICROSOFT EXCEL PAGE 03 Opening Microsoft Excel Microsoft Excel Features Keyboard Review Pointer Shapes

More information

Pong in Unity a basic Intro

Pong in Unity a basic Intro This tutorial recreates the classic game Pong, for those unfamiliar with the game, shame on you what have you been doing, living under a rock?! Go google it. Go on. For those that now know the game, this

More information

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software.

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software. Welcome to Basic Excel, presented by STEM Gateway as part of the Essential Academic Skills Enhancement, or EASE, workshop series. Before we begin, I want to make sure we are clear that this is by no means

More information

(Refer Slide Time: 00:23)

(Refer Slide Time: 00:23) In this session, we will learn about one more fundamental data type in C. So, far we have seen ints and floats. Ints are supposed to represent integers and floats are supposed to represent real numbers.

More information

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ). AS12 Assembler Directives A Summary of 9S12 instructions Disassembly of 9S12 op codes Huang Section 1.8, Chapter 2 MC9S12 V1.5 Core User Guide Version 1.2, Section 12 o A labels is a name assigned the

More information

CREATING CONTENT WITH MICROSOFT POWERPOINT

CREATING CONTENT WITH MICROSOFT POWERPOINT CREATING CONTENT WITH MICROSOFT POWERPOINT Simple Tips And Tricks Presented by TABLE OF CONTENTS Introduction... 2 Design Tips... 3 Advanced Tips... 4 ShortCut Keys for Microsoft PowerPoint... 5 How-Tos...

More information

Long Live the HP-15C!

Long Live the HP-15C! Long Live the HP-15C! Valentín Albillo (Ex-PPC #4747, HPCC #1075) According to Wlodek s superb Guide to HP Handheld Calculators and Computers, the HP-15C was released in July, 1982, and it was meant to

More information

[301] Bits and Memory. Tyler Caraza-Harter

[301] Bits and Memory. Tyler Caraza-Harter [301] Bits and Memory Tyler Caraza-Harter Ones and Zeros 01111111110101011000110010011011000010010001100110101101 01000101110110000000110011101011101111000110101010010011 00011000100110001010111010110001010011101000100110100000

More information

Introduction to Access 97/2000

Introduction to Access 97/2000 Introduction to Access 97/2000 PowerPoint Presentation Notes Slide 1 Introduction to Databases (Title Slide) Slide 2 Workshop Ground Rules Slide 3 Objectives Here are our objectives for the day. By the

More information

Algebraic Expressions & Models L1.2. Welcome Back! Get your stuff out and be ready to go when the bell rings!

Algebraic Expressions & Models L1.2. Welcome Back! Get your stuff out and be ready to go when the bell rings! Welcome Back! Get your stuff out and be ready to go when the bell rings! 1 2 Variable: 3 Variable: Letter that represents one or more numbers 4 Variable: Letter that represents one or more numbers Expression:

More information

Free for personal use but you must have written permission to reproduce

Free for personal use but you must have written permission to reproduce www.commodore.ca www.commodore.ca Commodore Business Machines, Inc. 901 California Avenue Palo Alto, California 94304, USA Commodore/MOS Valley Forge Corporate Center 950 Rittenhouse Road Norristown, Pennsylvania

More information

Hello App Inventor! Android programming for kids and the rest of us. Chapter 2. by Paula Beer and Carl Simmons. Copyright 2015 Manning Publications

Hello App Inventor! Android programming for kids and the rest of us. Chapter 2. by Paula Beer and Carl Simmons. Copyright 2015 Manning Publications SAMPLE CHAPTER Hello App Inventor! Android programming for kids and the rest of us by Paula Beer and Carl Simmons Chapter 2 Copyright 2015 Manning Publications Brief contents 1 Getting to know App Inventor

More information

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology. Guide to and Hi everybody! In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology. This guide focuses on two of those symbols: and. These symbols represent concepts

More information

Project 3: RPN Calculator

Project 3: RPN Calculator ECE267 @ UIC, Spring 2012, Wenjing Rao Project 3: RPN Calculator What to do: Ask the user to input a string of expression in RPN form (+ - * / ), use a stack to evaluate the result and display the result

More information

Term Definition Introduced in: This option, located within the View tab, provides a variety of options to choose when sorting and grouping Arrangement

Term Definition Introduced in: This option, located within the View tab, provides a variety of options to choose when sorting and grouping Arrangement 60 Minutes of Outlook Secrets Term Definition Introduced in: This option, located within the View tab, provides a variety of options to choose when sorting and grouping Arrangement messages. Module 2 Assign

More information

Operating Systems. Objective

Operating Systems. Objective Operating Systems Project #1: Introduction & Booting Project #1: Introduction & Booting Objective Background Tools Getting Started Booting bochs The Bootloader Assembling the Bootloader Disk Images A Hello

More information