1 / 22

Computer Organization Lecture 4

Computer Organization Lecture 4. Assembly language programming ALU and memory instructions. Memory. Registers. ALU. MIPS: Programmers View. We will design a subset of this computer. Stack. Data. Program. Memory Usage. Memory divided into three separate regions or segments.

gada
Download Presentation

Computer Organization Lecture 4

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. Computer OrganizationLecture 4 Assembly language programming ALU and memory instructions University of Portland School of Engineering

  2. Memory Registers ALU MIPS: Programmers View We will design a subset of this computer University of Portland School of Engineering

  3. Stack Data Program Memory Usage Memory divided into three separate regions or segments University of Portland School of Engineering

  4. Assembly programming This could be compiled Sources files are assembled, then linked University of Portland School of Engineering

  5. Assembler • Purpose: translates a program statement (source file) into an address and data (object file) • Steps (2-pass) • Create a symbol table • Use symbol table to generate instruction as a binary number • Execution: OSwrites program into memory, transfers control, program runs, control returns to OS University of Portland School of Engineering

  6. Program statement syntax • Generally, free-format • Comments: begin with sharp (#) # this is a comment • Labels: start the beginning of a line, end with colon (:) start: loop: end: University of Portland School of Engineering

  7. Memory addresses • Notation: c(rx) rx = register/base c = constant/offset • Examples 100($t0) # EA = $t0 + 100 0x2f ($22) # EA = $22 + 0x 2f ($sp) # EA = $sp, c = 0 University of Portland School of Engineering

  8. Directives • Provides assembler information • Start with dot (.) • Examples .text # start text segment .data # start data segment .asciiz # null terminated string .word # insert word data University of Portland School of Engineering

  9. A typical line of code label: opCode $destination, $operand1, $operand2, #comment • Examples • loop: li $t0, 2 # initialize $t0 = 2 • calc: add $t1, $t3, $t1 # $t1 = $t3 + $t1 • nop # do nothing • mult $s2, $s3 # hi:lo = $s2 x $s3 University of Portland School of Engineering

  10. Program Directives Labels Program Structure University of Portland School of Engineering

  11. Simple Program University of Portland School of Engineering

  12. Let’s run the program University of Portland School of Engineering

  13. Write the program? Subtract 3 from 5 and leave in $t2 University of Portland School of Engineering

  14. Instruction Classes • Arithmetic and logic • Load • Store • Comparison • Branch and jump • Data Movement • Floating Point University of Portland School of Engineering

  15. Arithmetic and Logic Only registers used for operands University of Portland School of Engineering

  16. Loads (reg  mem) The point of reference is a register University of Portland School of Engineering

  17. Stores (reg  mem) The point of reference is a register University of Portland School of Engineering

  18. Accessing Memory • Use the la instruction to place address in a register • Use the load/from & store/to address saved in the register la $t0, var # $t0 = address of var: lw $v1, ($t0) # $v1 = var sw $s0, 4($t0) # mem[var + 4] = $s0 University of Portland School of Engineering

  19. Write the program? NOTE: data movement, mflo $reg University of Portland School of Engineering

  20. University of Portland School of Engineering

  21. Write the program? Subtract 3 from 5 and leave in $t2 University of Portland School of Engineering

  22. Write the program? University of Portland School of Engineering

More Related