1 / 23

PseudoInstructions

PseudoInstructions. 21 - Extended Assembler. Pseudoinstructions Instructions defined at assembly level Assembler translates to machine intsructions. Intent. Intent signaling instructions. Convenience. lw : Load word with label Sets up base address/offset. Convenience.

don
Download Presentation

PseudoInstructions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PseudoInstructions

  2. 21 - Extended Assembler • Pseudoinstructions • Instructions defined at assembly level • Assembler translates tomachine intsructions

  3. Intent • Intent signaling instructions

  4. Convenience • lw : Load word with label • Sets up base address/offset

  5. Convenience • sw : Store register to labeled memory

  6. Load Address • la : Load Address • Get memory address of labeled item • Assembly pointer

  7. Other Pseudo Tricks (23) • Immediate value impliesimmediate instruction • Convenience math/logic

  8. Assembler Temporary Register • Instructions requiring multiple steps built using $1

  9. Registers • Registers have meanings defined by convention • Can use memnonic names instead of numbers

  10. Registers • Tips: • Avoid $0, $1and $26-$31 • $8-$25 safe for now :$t0-$t9 and $s0-$s7

  11. 24 – More Pseudo • Whole bunch o' branches and sets:

  12. Indexed Addressing • Arrays last week: • Move baseaddress around

  13. Unnatural • Offset/Base addressing ofteninconvenient • Indexed Addressing • Label(Offset)Array[i]

  14. Arrays Now • Arrays now • Change offset, uselabel as baseaddress

  15. Interrupts • Interrupt: signal to CPU that something needs to happen • Hardware Interrupts • Input/output ready • Ctrl-C • Code needs help • Trap from math overflow • Request for OS

  16. Interrupt Handling • OS take over • Saves stateof running program • Runs interrupt handler • Restores state

  17. 22 - Syscalls • syscall: program generated interruptOperating System please do something • Use registers to send/receive information

  18. Syscalls • Syscall codes:

  19. MIPS cin / cout • Read and print integer:

  20. More Syscalls • Properly end the program:

  21. Print String • Strings usually longer than word • Live in memory, not registers • String syscalls need pointer to string : $a0 • Prints bytes until null char (00)

  22. Read Print Int 3 Print promptand answermessages:

  23. Read String • Read string code needs • Location to write to • Space available

More Related