TRAPS and Multiple Files Programming Lab #4 CEG 3310/5310: Computer Organization PURPOSE In this lab you will learn how
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
TRAPS and Multiple Files Programming Lab #4 CEG 3310/5310: Computer Organization PURPOSE In this lab you will learn how
GETTING STARTED You are provided 5.asm files and you only have to modify 2 of them: • main_lab4.asm o Do not modify this file o This file exists to run your trap calls x40 and x41 • trap_vector_input.asm o Do not modify this file o This file puts the address x4000 into the TRAP vector at location x40 • trap_vector_output.asm o Do not modify this file o This file puts the address x5000 into the TRAP vector at location x41 • trap_input.asm o This is where you write your PART 1 code o Use this file to write your hex character input • trap_output.asm o This is where you write your PART 2 code o Use this file to write your memory dump output To get started drag these .asm files into your simulator in this order: 1. trap_vector_input.asm 2. trap_vector_output.asm 3. trap_input.asm 4. trap_output.asm 5. main_lab4.asm Without writing any code yet, you can continually press "Step" in your simulator to see how the unmodified works. The first TRAP call (x40) takes your program to address x4000, once you implement code in x4000 you should have your starting address of your memory dump in RO. • • • The second TRAP call (x40) takes your program to address x4000, again, and this will put your ending address of your memory dump inside of RO. The last TRAP call (x41) takes your program to address x5000, which will use addresses RO for your starting address, and R1 for your ending address. PART 1 To implement trap_input.asm you must do the following: You must read a users input of "x####" where the #'s are hex digits Once you have the 4 hex digits you must store the hex values in RO For example: if user types the ASCII characters "xA1B5" then at the end of your TRAP call RO must contain the value "xA1B5" NOTE: This is very tricky! For example the ASCII value "A" will be read from the keyboard in HEX as "x0041", somehow you must convert this to "x000A". Also, the ASCII value "0" will be read from the keyboard in HEX as "x0030" • So if the user enters "xA1B5" 5 different values will be read in this order: O x0078
• O x0041 x0031 x0042 O x0035 o x000A After all these inputs RO must read: O XA1B5 • This TRAP call should function properly even after being called multiple times, you will need to call this TRAP function at least twice to complete this lab (to get your starting and ending addresses). • EXTRA CREDIT: You must only implement reading UPPERCASE hex values. If you implement LOWERCASE letters as well, such as "xa1b5" then you will be given +1% extra credit to total class grade • EXTRA CREDIT: You can assume that a user will always enter a valid input. You do not have to check for errors. For example if a user enters "xZ#5p" you can process it as if it was a valid input. If you do implement valid input checking you will be give +2% extra credit to total class grade PART 2 To implement trap_output.asm you must do the following: • Using RO as your starting address and R1 as your ending address Cycle through memory addresses and display the contents to the user • For example, if RO contains x3000 and R1 contains x3003 then the display on the console should look as follows: Memory contents x3000 to x3003: x3000 xF030 x3001 xB006 x3002 xF040 x3003 xB005 • NOTE: This is tricky as well, you must convert an address/data inside register to a string. For example: o Address/Data in Register: ■x3000 o String that will get stored in memory: ■ x0078 ■ x0033 ■x0030 ■x0030 x0030 x0000 • EXTRA CREDIT: You do not have to check if R1> RO. If you do check R1 > RO and display a message to the user "The starting address is smaller than the ending address!" then you will be given +1% extra credit to total class grade GRADING • Input TRAP implemented properly: 5 points
ASM main_lab4-su22.asm X C: > Users > johns > Desktop > Lab04> ASM main_lab4-su22.asm 1 ORIG X3000 2 TRAP x40 3 ST RØ, FIRST_ADDRESS 4 5 6 TRAP x40 ST RØ, LAST_ADDRESS 7 8 9 10 11 12 13 14 15 FIRST_ADDRESS .BLKW #1 16 LAST_ADDRESS .BLKW #1 17 18 19 LD RØ, FIRST_ADDRESS LD R1, LAST_ADDRESS TRAP x41 HALT .END
trap_input-su22.asm X C: > Users > johns > Desktop > Lab04> ASM trap 1 .ORIG X4000 ;WRITE YOUR CODE HERE 2 3 4 RET .END
ASM trap_output-su22.asm X C: > Users > johns > Desktop > Lab04> ASM .ORIG X5000 1 2 ;WRITE YOUR CODE HERE RET .END 3 4
ASM trap_vector_input-su22.asm X C: > Users > johns > Desktop > Lab04 > 1 .ORIG X0040 2 3 .FILL X4000 . END
ASM trap_vector_output-su22.asm X C: > Users > johns > Desktop > Lab04> ASM † 1 ORIG X0041 2 .FILL X5000 3 . END