5e 7e us 1f 3f 5f del 7f trap service routines trap

This preview shows page 9 - 10 out of 10 pages.

5E ~ 7E us 1F ? 3F _ 5F del 7F Trap Service Routines Trap Vector Assembler Name Description x20 GETC Read a single character from the keyboard. The Character is not echoed onto the console. Its ASCII code is copied into R0. The high eight bits of R0 are cleared. x21 OUT Write a character in R0[7:0] to the console display. x25 HALT Halt execution and print a message on the console. 9
Image of page 9

Subscribe to view the full document.

9 LC-3 Instruction Set ( Entered by Mark D. Hill on 03/14/2007; last update 03/15/2007 ) PC’: incremented PC. setcc(): set condition codes N, Z, and P. mem[A]:memory contents at address A. SEXT(immediate): sign-extend immediate to 16 bits. ZEXT(immediate): zero-extend immediate to 16 bits. Page 2 has an ASCII character table. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ ADD DR, SR1, SR2 ; Addition | 0 0 0 1 | DR | SR1 | 0 | 0 0 | SR2 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR barb2left SR1 + SR2 also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ ADD DR, SR1, imm5 ; Addition with Immediate | 0 0 0 1 | DR | SR1 | 1 | imm5 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR barb2left SR1 + SEXT(imm5) also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ AND DR, SR1, SR2 ; Bit-wise AND | 0 1 0 1 | DR | SR1 | 0 | 0 0 | SR2 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR barb2left SR1 AND SR2 also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ AND DR, SR1, imm5 ; Bit-wise AND with Immediate | 0 1 0 1 | DR | SR1 | 1 | imm5 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR barb2left SR1 AND SEXT(imm5) also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ BRx, label (where x = {n,z,p,zp,np,nz,nzp}) ; Branch | 0 0 0 0 | n | z | p | PCoffset9 | GO barb2left ((n and N) OR (z AND Z) OR (p AND P)) +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ if (GO is true) then PC barb2left PC’ + SEXT(PCoffset9) +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ JMP BaseR ; Jump | 1 1 0 0 | 0 0 0 | BaseR | 0 0 0 0 0 0 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ PC barb2left BaseR +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ JSR label ; Jump to Subroutine | 0 1 0 0 | 1 | PCoffset11 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ R7 barb2left PC’, PC barb2left PC’ + SEXT(PCoffset11) +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ JSRR BaseR ; Jump to Subroutine in Register | 0 1 0 0 | 0 | 0 0 | BaseR | 0 0 0 0 0 0 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ temp barb2left PC’, PC barb2left BaseR, R7 barb2left temp +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ LD DR, label ; Load PC-Relative | 0 0 1 0 | DR | PCoffset9 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR barb2left mem[PC’ + SEXT(PCoffset9)] also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ LDI DR, label ; Load Indirect | 1 0 1 0 | DR | PCoffset9 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR barb2left mem[mem[PC’ + SEXT(PCoffset9)]] also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ LDR DR, BaseR, offset6 ; Load Base+Offset | 0 1 1 0 | DR | BaseR | offset6 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR barb2left mem[BaseR + SEXT(offset6)] also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ LEA, DR, label ; Load Effective Address | 1 1 1 0 | DR | PCoffset9 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR barb2left PC’ + SEXT(PCoffset9) also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ NOT DR, SR ; Bit-wise Complement | 1 0 0 1 | DR | SR | 1 | 1 1 1 1 1 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR barb2left NOT(SR) also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ RET ; Return from Subroutine | 1 1 0 0 | 0 0 0 | 1 1 1 | 0 0 0 0 0 0 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ PC barb2left R7 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ RTI ; Return from Interrupt | 1 0 0 0 | 0 0 0 0 0 0 0 0 0 0 0 0 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ See textbook (2 nd Ed. page 537).
Image of page 10

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern