开发者

Assembly Programming and Interrupt Handling

I'm writing a program in assembly using MIPS architecture for a class, and I'm having trouble figuring out how to grab an input character by a user and store it in a register to process.

The program would open a console, output a message, the user can then input 开发者_JS百科a character and then this determines what is supposed to happen next in the program.

Like I said, I'm having trouble figuring out how to grab the character so that I can act upon it in the program.

thanks


This is a very good starting point: MIPS Quick Tutorial

Here is a snippet from the tutorial

li  $v0, 5          # load appropriate system call code into register $v0;
                    # code for reading integer is 5
syscall           # call operating system to perform operation
sw  $v0, int_value  # value read from keyboard returned in register $v0;
                     # store this in desired location

You won't be working directly with interrupts with any assembly you are writing in user-space.


Write exception code. Interrupt (Exception) service routine starts at 0x80000180 (on QtSpim, PCSpim) Read the keyboard register. Data is at 0xFFFF0004. Grab the char. Then return from exception.

Or, you can poll keyboard status at 0xFFFF0000. When ready bit is on, read the data.

jjc.hydrus.net/cs61c/handouts/interrupts2.pdf

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜