Sprint-Challenge--Computer-Architecture

Binary, Decimal, and Hex

Complete the following problems:

  • Convert 11001111 binary

    to hex: CF

    to decimal: 207

  • Convert 4C hex

    to binary: 01001100

    to decimal: 76

  • Convert 68 decimal

    to binary: 01000100

    to hex: 44

Architecture

Short answer:

  • Explain how the CPU provides concurrency or parallelism:

    Either the CPU is divided into copies of itself, "cores", in which processes can be processed "in parallel", or there is a single CPU that processes instructions one at a time using time-sharing principles or pipelining.

  • Describe assembly language and machine language:

    Assembly language is a "low-level" programming language that is usually similar to the machine's architecture instructions. Machine language is something that can be directly exectued by a particular machine's architecture. All programming lanaguages are eventually compiled into machine code prior to execution, unless that language is the machine langauge already.

Coding

Options for submission, whichever is easier for you:

  • Copy your source into this repo, or...
  • Submit a PR for the Sprint Challenge from the Computer-Architecture-One repo you've been using all along.

Sprint Challenge:

See the LS-8 spec for details

Add the CMP instruction and equal flag to your LS-8.

Add the JMP instruction.

Add the JEQ and JNE instructions.

Here is some code that exercises the above instructions. It should print:

1
4
5
# Code to test the Sprint Challenge
#
# Expected output:
# 1
# 4
# 5

10011001 # LDI R0,10
00000000
00001010
10011001 # LDI R1,20
00000001
00010100
10011001 # LDI R2,TEST1
00000010
00010011
10100000 # CMP R0,R1
00000000
00000001
01010001 # JEQ R2        Does not jump because R0 != R1
00000010
10011001 # LDI R3,1
00000011
00000001
01000011 # PRN R3        Prints 1
00000011

# TEST1 (19):
10011001 # LDI R2,TEST2
00000010
00100000
10100000 # CMP R0,R1
00000000
00000001
01010010 # JNE R2        Jumps because R0 != R1
00000010
10011001 # LDI R3,2
00000011
00000010
01000011 # PRN R3        Skipped--does not print
00000011

# TEST2 (32):
10011001 # LDI R1,10
00000001
00001010
10011001 # LDI R2,TEST3
00000010
00110000
10100000 # CMP R0,R1
00000000
00000001
01010001 # JEQ R2        Jumps becuase R0 == R1
00000010
10011001 # LDI R3,3
00000011
00000011
01000011 # PRN R3        Skipped--does not print
00000011

# TEST3 (48):
10011001 # LDI R2,TEST4
00000010
00111101
10100000 # CMP R0,R1
00000000
00000001
01010010 # JNE R2        Does not jump because R0 == R1
00000010
10011001 # LDI R3,4
00000011
00000100
01000011 # PRN R3        Prints 4
00000011

# TEST4 (61):
10011001 # LDI R3,5
00000011
00000101
01000011 # PRN R3        Prints 5
00000011
10011001 # LDI R2,TEST5
00000010
01001001
01010000 # JMP R2        Jumps unconditionally
00000010
01000011 # PRN R3        Skipped-does not print
00000011

# TEST5 (73):
00000001 # HLT