- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
printList((p)next)课件
The MIPS stack: recap
The stack grows downward in terms of memory addresses.
The address of the top element of the stack is stored (by convention) in the “stack pointer” register, $sp.
0($sp), 1($sp), … are “used” locations
-1($sp), -2($sp), … are “free”
MIPS does not provide “push” and “pop” instructions. Instead, they must be done explicitly by the programmer.
“push” $t0 simulated with:
sub $sp, $sp, 4 # $t0 needs 4 bytes
sw $t0, 0($sp) # write to stack
“pop” $t0 simulated with:
lw $t0, 0($sp) # read stack top
addi $sp, $sp, 4 # free 4 bytes
0x7FFFFFFF
0$sp
stack
堤惟猪盾妮矮蝗良花邪瑟虏白进签主鞭汐睦桂洋夯味层拦冒握匹爸衬碌比printList((p)next)课件CS232 @ UIUC
Using the stack: MP 2’s main
Performs a jal, so must save $ra before and restore it afterwards
main:
addi $sp, $sp, -4 # grow stack
sw $ra, 0($sp) # save callee-saved register $ra
jal iterTraverse # call your function
lw $ra, 0($sp) # restore $ra
addi $sp, $sp, 4 # shrink stack
jr $ra
A jal to a function
Will cause a malfunction
If ra is not on the stack
And caller-saved regs
Should be handled like eggs
Theyre junk when the function comes back
And lastly, no messes
In each of the esses
Make sure you restore em - dont slack!
清铡清骚鞘啸旅杭殴宣仔元班险援裔揖赶殉喝熟汗雨劣椒葵颁饱叙遵吱妒printList((p)next)课件CS232 @ UIUC
Practice with pointers: Linked Lists
Linked lists are implemented in C using structures as follows:
struct node {
int data; // data field
node* next; // pointer to next node in list
}
If p is a pointer to a node, then
*p is the node itself
(*p).data is located at address p in memory
(*p).next is located at address p + sizeof(data) in memory
If p points to the last node in the list, (*p).next == NULL.
If t0 points to a node, then the statement t0 = (*t0).next makes t0 point to the next node in the list.
The above statement can be translated into MIPS as:
lw $t0, 4($t0)
Translate the following C statements into MIPS:
(*t0).data = (*t1).data;
(*t0).next
您可能关注的文档
- PMC_项目监控课件.ppt
- Pleegzorg, een haalbaar alternatief课件.ppt
- PNEUMATECH_产品技术介绍(PHC再生式干燥机)课件.ppt
- PN_OFFSET 规划课件.ppt
- PodatkiIzdelava anketnega vpra alnika课件.ppt
- point of view课件.ppt
- politeness principle课件.ppt
- Politics in Newspapers lecture 2课件.ppt
- politics课件.ppt
- political system, education and economy of Nz课件.ppt
- Principle of structure dependency课件.ppt
- principles of Physics--22polarization课件.ppt
- PRE_PPT_CHAP3_V1.0课件.ppt
- Principles of Flight课件.ppt
- prime numbers and sum numers课件.ppt
- Problem Solving Tool_8D_CAR_X01_20091216课件.ppt
- Prisma调较维修课件.ppt
- Pro-Intralink 基础知识课件.ppt
- Problems and Future Uses课件.ppt
- Privacy and Employment Torts课件.ppt
最近下载
- 2023年下半年广西普通高中学业水平合格性考试数学真题试卷含答案.docx VIP
- 量子计算性能评估基准研究报告 202412.pdf VIP
- 全国第三届职业技能大赛(劳动关系协调师)选拔赛理论考试题库(含答案).docx VIP
- 胃癌临床表现.pptx VIP
- 不不兔课件.ppt VIP
- 《无机化学与化学分析》课程思政案例.docx VIP
- 2025辽宁沈阳城市建设投资集团所属企业沈阳国际工程咨询集团有限公司招聘11人笔试备考试题及答案详解.docx VIP
- (高清版)DB5119∕T 21-2021 地理标志产品 江口醇酒生产技术规范 .pdf VIP
- 拆除工程安全技术规范.pdf VIP
- 考研真题 天津外国语大学801英语语言文学(英美文学方向)历年考研真题汇编.docx VIP
文档评论(0)