Reference no: EM132324208
Instruction Set and Library Lab
• For this lab you will be using a library cs12Lib.o
• And using basic math statements to write assembly code using integer arithmetic
Project 1:
Using the next two slides create a logic project
• You will want to create a project named kayak
Create a fresh project
use your own name for projectName
Go to the CS12-Libs Directory
git pull
cd template
./createProject projectName cd ../projectName
make
./projectName
Blank project file
You can use this for future projects as well
The createProject will do the following
Create a directory Create a basic .asm file
Create a Makefile for this project make will build the project make clean will clean up the files Use pico to edit the .asm file
Palindrome
• A palindrome is word that reads the same forward or backwards.
• For example,
• "anna"
• "civic"
• "hanah"
• "kayak"
• "madam"
• Are palindromes.
Create a Palindrome Checker
Create a program to determine if a carriage return (0x0a) terminated byte array representing a word is a palindrome.
This can be accomplished by pushing the characters on the stack one at a time (until a 0x0a is detected) and then popping from the stack and comparing to the byte array starting from the beginning.
• The program will perform the following:
• Print CS12 to the screen
• Prompt the user to enter a byte array of max 25 characters
• Determine if the byte array is the same forwards and backwards using the stack
• Print either:
• Is a palindrome!
• Is not a palindrome!
Project 2:
• You will want to create a project named sort
Create a fresh project
use your own name for projectName
Go to the CS12-Libs Directory
git pull
cd template
./createProject projectName cd ../projectName
make
./projectName
You should see CS12 print out
Blank project file
You can use this for future projects as well
The createProject will do the following
Create a directory Create a basic .asm file
Create a Makefile for this project
make will build the project
make clean will clean up the files Use pico to edit the .asm file
Create a program that will reverse then sort a set of 5 characters input by the user
• The program will perform the following:
• Print CS12 to the screen
• Query the user "Input 5 Characters"
Read in the characters
faced
• Print ‘Reverse' then the characters in reverse order
Reverse decaf
• Print ‘Sorted' then the characters in sorted order
Sorted acdef
• Note: see the next slides for reverse and sort requirements
Reverse
• The output of your reverse should be exactly the reverse of the input characters
• a-z, A-Z, 0-9
• abcde yields edcba
• ApPle yields elPpA
• AbCdE yields EdCbA
• 1a2B3 yields 3B2a1
• 13579 yields 97531
Sort
• The sort algorithm is bases on the numeric value of the ASCII Character
• This means the characters are sorted as follows
Characters
|
Order
|
ASCII Values
|
0-9
|
First
|
0x30 - 0x39
|
A-Z
|
Second
|
0x41 - 0x5A
|
a-z
|
Third
|
0x60 - 0x7A
|
What to turn in
• Turn in a screen shot of your program run
• Turn in the sort.asm file that generates your output
• Your output should match examples, and work for various values using alpha numeric characters as listed below
• a-z
• A-Z
• 0-9
Note: other characters will not be used in grading
Project 3:
There will be 3 files in the directory
• Three files:
• cards.asm
• driver.asm
• Makefile
• We can use the following make commands:
make this will make: cards make cards this will make: cards make driver this will make: driver make all this will make both make clean clean the directory
Cards and Driver
• Often when were trying to develop a function we create a test program called a driver
• For our Cards project I have included a driver program that will test the macros, and later our functions (future lab)
The driver program will fail as shown
• There are 4 macros that need to be filled in.
pushAll popAll newDeck displayValue
• Note the failure messages to the left when these pass the macros are working
• Fill in each macro to make it run in the driver program
• To test you will save the driver program driver.asm
• Make the driver make driver
• Run the driver program
./driver
• And check for a successful run
Attachment:- Lab.rar