Welcome to CMPE 12C University of California, Santa 欢迎来到加利福尼亚大学CMPE 12C圣诞老人.pptVIP

  • 5
  • 0
  • 约5.72千字
  • 约 31页
  • 2017-03-09 发布于上海
  • 举报

Welcome to CMPE 12C University of California, Santa 欢迎来到加利福尼亚大学CMPE 12C圣诞老人.ppt

Welcome to CMPE 12C University of California, Santa 欢迎来到加利福尼亚大学CMPE 12C圣诞老人

LC-3 Assembly Language Patt and Patel Ch. 7 LC-3 is a load/store RISC architecture Has 8 general registers Has a flat 16-bit addressing range Has a 16-bit word size Load variables from memory to register Syntax of LC-3 One instruction, declaration per line Comments are anything on a line following “;” Comments may not span lines LC-3 has 2 basic data types Integer Character Both are take 16-bits of space (a word) though a character is only 8-bits in size. Labels Symbolic names that are used to identify memory locations Location for target of a branch or jump Location for a variable for loading and storing Can be 1-20 characters in size .ORIG Tells simulator where to put your code in memory Only one allowed per program PC gets set to this address at start up Similar to the “main” in “C” .FILL One declaration per line Always declaring 16-bits, the word size of LC-3 .BLKW Tells assembler to set aside some number of sequential memory locations Useful for arrays Can be initialized Examples of .BLKW: ;set aside 3 locations .BLKW 3 ;set aside 1 location and label it. Bob .BLKW 1 ;set aside 1 location, label and init to 4. Num .BLKW 1 #4 .STRINGZ Used to declare a string of characters Is terminated by x0000 Example: hello .STRINGZ “Hello World!” .END Tells the assembler where your program ends Only one per allowed in your program Simple LC-3 program What does this program do? What is in “Result” at the end? Assembler translates to executable – machine language Linker combines multiple LC-3 files – if any Loader puts executable into memory and makes the CPU jump to first instruction, .ORIG. Executes When executing is done returns control to OS Or simulator or monitor Load again to run again with different data In this case, assemble again, too, since data is in program. HLL – if/else statements… Procedure Calls “LC-3” LD R0, a AND R1, R1, #0 ; init I to zero ADD R1, R1, #3 ; now make 3 for ADD R2, R1, #-8 BRp endfor ADD R0, R0, R1

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档