码迷,mamicode.com
首页 > 其他好文 > 详细

CCPS310 – COMPUTER ORGANIZATION II

时间:2019-03-25 19:18:06      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:sub   oca   cap   ready   alt   window   int   student   specific   


CCPS310 – COMPUTER ORGANIZATION II
LAB 2 (7%)
ARC MEMORY MAPPED I/O
Submission instruction:
Students work in groups of 2, and are expected to do the lab together. If you
are doing in group of 2- only have one member submit the lab
Due: March 23 @23:00
Doing I/O using ARC Memory Mapped I/O
ARC does not have any explicit I/O instructions. I/O is then done by reading from and
writing to pre-defined memory locations in the memory which are assigned to I/O
devices. This is known as memory mapped I/O. Each I/O device has a data port.
Similarly, each device has a status port that is used to test the readiness status of the
I/O device.
For the purpose of this lab, we are interested in using the ARC simulator to use:
- The console output port to display characters
- The keyboard input port to read characters
1) Please provide comments for all instructions.
2) What is the memory mapped address for the console output and keyboard input?
3) Please identify the specific line of code that prints to console and reads the
keystroke.
PART A – Output: Printing character to the display
The memory addresses associated with the console output I/O device are:
- 0xffff0000 is the console (output) data port
- 0xffff0004 is the console (output) status port where bit 7 is the ready flag (0: not
ready, 1: ready)
Printing a character is achieved by:
- Checking the ready flag to see if device is ready for printing, i.e., check if the bit 7
of the output status port is set to 1
- Storing the character to the output data port
! Prints "Hello, world!\n" in the message area.
.begin
2
BASE .equ 0x3fffc0 !Starting point of the memory mapped region
COUT .equ 0x0 !0xffff0000 Console Data Port
COSTAT .equ 0x4 !0xffff0004 Console Status Port
.org 2048
add %r0, %r0, %r2
add %r0, %r0, %r4
sethi BASE, %r4
Loop: ld [%r2 + String], %r3 !Load next char into r3
addcc %r3,%r0,%r3
be End ! stop if null
Wait: ldub [%r4+COSTAT], %r1
andcc %r1, 0x80, %r1
be Wait
stb %r3, [%r4+COUT] !Print to console
add %r2, 4, %r2 !increment String offset (r2)
ba Loop
End: halt !A non-standard instruction to stop the simulator
.org 3000
! The "Hellow, world!" string
String: 0x48, 0x65, 0x6c, 0x6c, 0x6f
0x2c, 0x20, 0x77, 0x6f, 0x72
0x6c, 0x64, 0x21, 0x0a, 0
.end
PART B – INPUT: Accepting character from the keyboard
The memory addresses associated with the keyboard input I/O device are:
- 0xffff0008 is keyboard (input) data port
- 0xffff000C is the keyboard (input) status port where bit 7 is the ready flag (0: not
ready, 1: ready)
Reading a character is achieved by:
- checking the ready flag to see if the keyboard is ready, i.e., check if the bit 7 is
set to 1
- loading the character from the keyboard data port
! Read a character from keyboard
.begin
BASE .equ 0x3fffc0 !Starting point of the memory mapped region
COUT .equ 0x0 !0xffff0000 Console Data Port
COSTAT .equ 0x4 !0xffff0004 Console Status Port.
CIN .equ 0x8 !0xffff0008 Keyboard Data Port
CICTL .equ 0xc !0xffff000c Keyboard Control Port
3
.org 2048
add %r0, %r0, %r4 !Clear r4
sethi BASE, %r4
InWait: halt
ldub [%r4 + CICTL], %r1
andcc %r1, 0x80, %r1
be InWait
ldub [%r4 + CIN], %r3
subcc %r3, 27, %r5 ! 27 is Escape
be End ! stop if it is.
Wait: ldub [%r4 + COSTAT], %r1
andcc %r1, 0x80, %r1
be Wait
stb %r3, [%r4 + COUT]
ba InWait
End: halt
.end
**Note: To enter keystrokes in ArcTool Simulator,
- Click on the Console (located at the bottom of the window)
- Enter Keystroke on your keyboard.
- Re-click Run Button

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:99515681@qq.com 

微信:codinghelp

CCPS310 – COMPUTER ORGANIZATION II

标签:sub   oca   cap   ready   alt   window   int   student   specific   

原文地址:https://www.cnblogs.com/helpyourjava/p/10595489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!