You are on page 1of 6

///////////////////////////////////////////////

//// FIT 1047 S1 2024, Assignment 2, Part 4


////

//// Student name:


//// Student email:
//// Student ID:

/ Main program: call the CountDown subroutine and then halt

JnS SubCountDown
Halt

//// Task 4.1: Clearing the screen

SubClearDisplay, HEX 0

Loop, Load White / Loads the address for white square into the AC
StoreI Address / Stores white at the desired location based on variable
Address
Load Address / Loads the current address into the AC
Add One / Adds one to the current address
Store Address / Updates the Address variable for the next memory location to
be made white
Load Max / Loads the number of black pixels left
Add One / Adds one to the negative number of pixels
Store Max / Updates the max variable
Skipcond 400 / If max = 0, the number of black pixels is 0 and the display is
white, so skips to halt
Jump Loop / If there are black pixels left, jumps to the top of the loop to
make the next pixel white
JumpI SubClearDisplay

White, HEX FFFF / Used to turn black pixels white


Max, DEC -256 / Keeps track of the number of pixels we have turned white
Address, HEX 0F00 / Address of the first pixel, updates after each pixel is turned
white
One, DEC 1 / Used to add one to the memory address and to keep track of black
pixels remaining

//// Task 4.2: Painting a number

/ TO DO: Add your subrouting for painting a character below.


PaintDigitCharacter, HEX 0
PaintDigitDisplay, HEX 0
SubPaintDigit, HEX 0
Load Zero
Subt Five
Store OuterCounter
OuterLoop, Load Zero
Add NegativeThree
Store InnerCounter
InnerLoop, LoadI PaintDigitCharacter
StoreI PaintDigitDisplay

Load PaintDigitCharacter
Add One
Store PaintDigitCharacter
Load PaintDigitDisplay
Add One
Store PaintDigitDisplay

Load InnerCounter
Add One
Store InnerCounter
Skipcond 400
jump InnerLoop

load PaintDigitDisplay
add Thirteen
store PaintDigitDisplay
load OuterCounter
Add One
store OuterCounter
Skipcond 400
jump OuterLoop
JumpI SubPaintDigit

Zero, DEC 0
Five, DEC 5
Fifteen, DEC 15
Thirteen, DEC 13
InnerCounter, DEC 0
OuterCounter, DEC -5
NegativeThree, DEC -3

//// Task 4.3: Count down

/ TO DO: Add your subroutine for the countdown, and any


/ additional subroutines you implement, below.

SubCountDown, HEX 0
Load FontAddr
Add OneThreefive
Store PaintDigitCharacter
OutsideLoop, Load Zero
Add NegativeFour
Store NumberCounter
InsideLoop, Load StartingDigit
Store PaintDigitDisplay
JnS SubPaintDigit

JnS Delay

Load NumPainted
Add One
Skipcond 000
jump FinishCountdown
Store NumPainted

Load PaintDigitCharacter
Subt Thirty
Store PaintDigitCharacter

Load StartingDigit
Add Four
Store StartingDigit
Load NumberCounter
Add One
Store NumberCounter

Skipcond 400
Jump InsideLoop

Load StartingDigit
Add SixtyFour
Store StartingDigit

Jump OutsideLoop
FinishCountdown, JumpI SubCountDown
SixtyFour, DEC 64
NumPainted, DEC -10
NumberCounter, DEC 0
Thirty, DEC 30
OneThreefive, DEC 135
Two, DEC 2
Four, DEC 4
NegativeFour, DEC -4
NegativeTwo, DEC -2
StartingDigit, HEX 0F00

Delay, HEX 0
Load Zero
Add Time
Store Timer
DelayLoop, Load Timer
Subt One
Store Timer
Skipcond 400
jump DelayLoop
JumpI Delay

Timer, DEC 0
Time, DEC 32
//////////////
//// Data
////

//// You don't need to change or add anything below

/ Address of the font data


FontAddr, Adr Font

/ The font data


/ Each character is 3 pixels wide and 5 pixels high.
/ It is represented as 15 consecutive words of memory,
/ in "row-major order". That means that the first three
/ words represent the top-most row of pixels, the next
/ three words the second row, and so on.

Font, HEX FFFF / Start of character 0


HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX 0
HEX FFFF
HEX 0
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX FFFF / Start of character 1
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX 0 / Start of character 2
HEX 0
HEX FFFF
HEX FFFF
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX 0
HEX 0
HEX 0 / Start of character 3
HEX 0
HEX FFFF
HEX FFFF
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX FFFF
HEX FFFF
HEX 0
HEX 0
HEX 0
HEX FFFF
HEX 0 / Start of character 4
HEX FFFF
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX 0
HEX 0
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX 0 / Start of character 5
HEX 0
HEX 0
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX 0
HEX FFFF
HEX FFFF
HEX FFFF
HEX 0
HEX 0
HEX 0
HEX FFFF
HEX FFFF / Start of character 6
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0 / Start of character 7
HEX 0
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX FFFF
HEX FFFF
HEX FFFF / Start of character 8
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX FFFF / Start of character 9
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX 0
HEX FFFF
HEX FFFF
HEX 0
HEX FFFF
HEX 0
HEX FFFF

You might also like