汇编实验报告.docx

上传人:b****3 文档编号:26586650 上传时间:2023-06-20 格式:DOCX 页数:29 大小:532.03KB
下载 相关 举报
汇编实验报告.docx_第1页
第1页 / 共29页
汇编实验报告.docx_第2页
第2页 / 共29页
汇编实验报告.docx_第3页
第3页 / 共29页
汇编实验报告.docx_第4页
第4页 / 共29页
汇编实验报告.docx_第5页
第5页 / 共29页
点击查看更多>>
下载资源
资源描述

汇编实验报告.docx

《汇编实验报告.docx》由会员分享,可在线阅读,更多相关《汇编实验报告.docx(29页珍藏版)》请在冰豆网上搜索。

汇编实验报告.docx

汇编实验报告

 

院系:

计算机科学学院

专业:

计算机科学与技术

年级:

200级

课程名称:

汇编语言程序设计

学号:

姓名:

指导教师:

 

年6月18日

 

年级

班号

 2

 学号

 

专业

计算机科学与技术

 姓名

实验

名称

 分类统计字符个数

实验

类型

设计型

综合型

创新型

*

 掌握分支程序设计的原理和方法,重点掌握各种分支程序中形成和判断条件而产生的程序段的设计方法和技巧。

 

 

 

 

 

 

 

 

 Yes

 

 No

 

 Yes

 

 

 No

Yes

 No

 

 No

Yes/no

 

测试结果如下:

 

教师签名:

年月日

源代码:

;Thisprogramcancountthenumberofcharactors,numeralandotherscharactors

;ofthestringthatuserinput.

;Aothor:

zhangdeng

;Date:

2009/11/11

.386

.MODELFLAT

INCLUDEio.h

ExitProcessPROTONEAR32stdcall,dwExitCode:

DWORD

crEQU0dh;回车

LfEQU0ah;换行

MaxNumEQU80;字符串长度

.STACK4096

.DATA

promptBYTE"Thisprogramcancountthenumberofcharactors,numeraland"

BYTE"otherscharactorsofthestringthatuserinput.",cr,Lf,0

OutputPromptBYTE"Pleaseinputastringforcount:

",cr,Lf

BYTE"Enter#toendinput.(1-80)",cr,Lf,0

stringBYTEMaxNumDUP(?

OutputCharNmbBYTE"Thenumberofcharactorsis:

",cr,Lf,0

CharNmb1DWORD?

OutputNumerlNmbBYTEcr,Lf,"Thenumberofnumeralis:

",cr,Lf,0

NumeralNmb1DWORD?

OutputOtherNmbBYTEcr,Lf,"Thenumberofotherscharactoris:

",cr,Lf,0

OtherNmb1DWORD?

CharNmbBYTE11DUP(?

NumeralNmbBYTE11DUP(?

OtherNmbBYTE11DUP(?

.CODE

_start:

outputprompt;输出程序功能

outputOutputPrompt;提示输入字符串

movCharNmb1,0;初始化字母字符变量为零

movNumeralNmb1,0;初始化数字字符为零

movOtherNmb1,0;初始化其他字符变量为零

inputstring,MaxNum;输入字符串

leaEBX,string;取出字符串地址

NumeralLoop:

movAL,[EBX];取出当前地址所指向的字符

cmpAL,'#';将字符与结束字符比较

jeFinalOutput;若是最后一个字符则结束

cmpAL,'0';将字符与0字符比较

jlCharLoop;若小于零则跳到CharLoop

cmpAL,'9';将字符与9比较

jgCharLoop;若大于9跳到CharLoop

incNumeralNmb1;数字变量加1

addEBX,1;地址下移,指向下一个字符

jmpNumeralLoop;跳到NumeralLoop

CharLoop:

cmpAL,'a';将字符与a比较

jlIfUper;若小于a则跳到IfUper

cmpAL,'z';将字符与z比较

jgIfUper;若大于z则跳到IfUper

incCharNmb1;字母字符变量加1

addEBX,1;地址下移,指向下一个字符

jmpNumeralLoop;跳到NumeralLoop

IfUper:

cmpAL,'A';将字符与A比较

jlOtherLoop;若小于A则跳到OtherLoop

cmpAL,'Z';将字符与Z比较

jgOtherLoop;若大于Z则跳到OtherLoop

incCharNmb1;字母字符变量加1

addEBX,1;地址下移,指向下一个字符

jmpNumeralLoop;跳到NumeralLoop

OtherLoop:

incOtherNmb1;其他字符变量加1

addEBX,1;地址下移,指向下一个字符

jmpNumeralLoop;跳到NumeralLoop

FinalOutput:

dtoaCharNmb,CharNmb1;将字母字符变量转化成ASCII码

outputOutputCharNmb;输出字母字符个数提示

outputCharNmb+8;输出字母字符个数

dtoaNumeralNmb,NumeralNmb1;将数字字符变量转化成ASCII码

outputOutputNumerlNmb;输出数字字符个数提示

outputNumeralNmb+8;输出数字字符个数

dtoaOtherNmb,OtherNmb1;将其他字符变量转化成ASCII码

outputOutputOtherNmb;输出其他字符个数提示

outputOtherNmb+8;输出其他字符个数

EndProcess:

INVOKEExitProcess,0;退出并返回零

PUBLIC_start;公开程序入口

END

 

年级

 

班号

 2

 学号

 

专业

 姓名

 

实验

名称

 现实九九乘法表

实验

类型

设计型

综合型

创新型

*

 掌握循环设计的原理和方法,重点掌握循环程序结构的形式和常用循环程序的控制方法和技巧

 流程图:

 

 

 

 

 

 

 

 

 是

 

 

 否

 

 否

 

 

 

 

<=

 

 

 >

 

实验结果:

源程序代码:

;Author:

zhangdeng

;Date:

2009/11/10

.386

.MODELFLAT

ExitProcessPROTONEAR32stdcall,dwExitCode:

DWORD

INCLUDEio.h

crEQU0dh

LfEQU0ah

.STACK4096

.DATA

DirectionBYTE"Thisprogramwilllistthemultiplicationtable.",cr,Lf,0

OutputPromptBYTE"9*9MULTIPLICATIONTABLE:

",cr,Lf,0

OutputCrLfBYTEcr,Lf,0

Multiplier1BYTE11DUP(?

BYTE"*",0

Multiplier2BYTE11DUP(?

BYTE"=",0

MultiplierBYTE11DUP(?

),0

.CODE

_start:

outputDirection;outputthefunctionofprogram

outputOutputPrompt;thepromptofoutput

movEBX,1;initializetheMultiplier1with1

movECX,0;initializetheMultiplier2with0

Multiplier1Loop:

incECX;add1toMultiplier2

movEAX,EBX;restoretheMultiplier1toEAX

movEDX,ECX;restoretheMultiplier2toEDX

mulEDX;counttheproduction

cmpEBX,ECX;Multiplier1comparedwithMultiplier2

jlMultiplier2Loop;ifMultiplier1

dtoaMultiplier1,EBX;convertMultiplier1toASCII

dtoaMultiplier2,ECX;convertMultiplier2toASCII

dtoaMultiplier,EAX;convertproductiontoASCII

outputMultiplier1+8;outputtheMultiplier1

outputMultiplier2+10;outputtheMultiplier2

outputMultiplier+9;outputtheproduction

jmpMultiplier1Loop;jumptoMultiplier1Loop

Multiplier2Loop:

outputOutputCrLf;outputcrandLf

incEBX;add1toMultiplier1

cmpEBX,10;Multiplier1comparedwith10

jgeEndProcess;ifthemultiplier1greaterthan10orequel10jumptoEndProcess

movECX,0,initializeMultiplier2with0

jmpMultiplier1Loop;jumptoMultiplier1Loop

EndProcess:

INVOKEExitProcess,0;exitwithreturncode0

PUBLIC_start;makeentrypointpublic

END;endofsourcecode

 

教师签名:

年月日

备注:

源代码附后,源代码要求有注释说明

 

年级

班号

 2

 学号

专业

 姓名

实验

名称

 将一个数组的所有元素排序后输出

实验

类型

设计型

综合型

创新型

*

 掌握子程序设计的原理和方法,重点掌握子程序编写和调用的过程以及堆栈操作和参数以及局部变量的概念。

 流程图:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

实验结果:

 

教师签名:

年月日

源代码:

;Thisprogramcansortanumber'sarray,

;thenoutputthenumbersofthearrayfromlowertohigher.

;Author:

zhangdeng

;Date:

2009/11/11

.386

.MODELFLAT

ExitProcessPROTONEAR32stdcall,dwExitCode:

DWORD

INCLUDEio.h

crEQU0dh

LfEQU0ah

.STACK4096

.DATA

DirectionBYTE"Thisprogramcansortanumber'sarray,thenoutputthenumbers",cr,Lf

BYTE"ofthearrayfromlowertohigher.(10)",cr,Lf,0

InputPromptBYTE"Pleaseinputanumberintothearray:

",cr,Lf,0

OutputPromptBYTE"Aftersorting,nowlistthenumbersofthearray:

",cr,Lf,0

NumberArrayDWORD10DUP(?

NumberDWORD?

.CODE

SwapFunctionProcNEAR32;thisaprocedureforswaptwovariable

UntillDone:

leaEBX,NumberArray;sourceaddresstoEBX

pushECX;sourceECX

SwapLoop1:

movEAX,[EBX];storeinEAX

cmpEAX,[EBX+4];comparedwiththenextnumber

jleSwapLoop2;iflesserorequeljumptoSwapLoop2

xchgEAX,[EBX+4];swapplacewiththenextnumber

mov[EBX],EAX;copythenextnumbertocurrentplace

SwapLoop2:

addEBX,4;add4toEBX

loopSwapLoop1;jumptoSwapLoop1

popECX;restoreregister

loopUntillDone;jumptoUntillDone

ret

SwapFunctionENDP;endtheprocedure

_start:

outputDirection;outputdirection

leaEBX,NumberArray;sourceaddresstoEBX

movECX,0;initializeECXwith0

WhilePos:

outputInputPrompt;outputInputPrompt

inputNumber,8;inputanumber

atodNumber;converttointeger

mov[EBX],EAX;storenumber

addEBX,4;thunkdownthenextaddress

incECX;add1toECX

cmpECX,10;comparedECXwith10

jeEndWhilePos;ifequeljumptoEndWhilePos

jmpWhilePos;jumptoWhilePos

EndWhilePos:

callSwapFunction;callSwapFunction

outputOutputPrompt;outputOutputPromt

leaEBX,NumberArray;sourcetheaddresstoEBX

movECX,0;copy0toECX

OutputLoop:

movEAX,[EBX];storeinEAX

dtoaNumber,EAX;converttoASCII,storeinmemory

outputNumber+4;outputnumber

addEBX,4;thunkdownthenextplace

incECX;add1toECX

cmpECX,10;comparedECXwith10

jeEndProcess;ifepueljumptoEndProcess

jmpOutputLoop;jumptoOutputLoop

EndProcess:

INVOKEEXitProcess,0;exitwithreturncode0

PUBLIC_start;makeentrypointpublic

END;endofsourcecode

 

年级

 

班号

 2

 学号

专业

 姓名

 

实验

名称

 

实验

类型

设计型

综合型

创新型

*

 掌握串操作指令的用法,注意DF标识位以及源串、目的串的存储和改变。

 流程图:

 

 

 

 

 

 

 

 

 

 

 

 

 

 没有

 

 

 

 存在

 不是

 

 

 

实验结果:

 

教师签名:

年月日

源代码:

;Author:

zhangdeng

;Date:

2009/12/2

.386

.MODELFLAT

ExitProcessPROTONEAR32stdcall,dwExitCode:

DWORD

INCLUDEio.h;headerfileforinput/output

crEQU0dh;carriagereturncharacter

LfEQU0ah;linefeed

.STACK4096;reserve4096-bytestack

.DATA;reservestoragefordata

DirectionBYTE"TheprogramcanfindcharacterAanduseareplaceit.",cr,Lf,0

InputPromptBYTE"Pleaseinputastring:

",cr,Lf,0

OutputPromptBYTE"Nowoutputnewstring:

",cr,Lf,0

TrgtStringBYTE80DUP(?

.CODE;startofmainprogramcode

StrLengthPROCNEAR32;calculatethelengthofstring

pushEBP;savebasepointer

movEBP,ESP;copystackpointer

pushf;saveflags

pushEBX;saveregister

subEAX,EAX;store0inEAX

movEBX,[EBP+8];source

WhileChar:

cmpBYTEPTR[EBX],0;isthelastposition?

jeEndWhileChar;ifisthelastpositionjumptoEndWhileChar

incEAX;add1toEAX

incEBX;addressthunkshift

jmpWhileChar;jumptoWhileChar

EndWhileChar:

popEBX;restoreregister

popf;restoreflags

popEBP;restorebasepointer

ret4;end

StrLengthENDP

_start:

outputDirection;outputthefunctionofthisprogram

outputInputPrompt;promptinputing

inputTrgtString,80;inputastring

leaEAX,TrgtString;addressofTrgtString

callStrLength;calculatethelengthofthestring

movECX,EAX;copythelengthofthestring

leaEDI,TrgtString;addressofTrgtStringstoreinEDI

ScanLoop:

movAL,'A';storeAinAL

scasb;searchstring

jneNotFound;ifthereisn'tA,jumptoNotFound

movAL,'a';storeainAL

subEDI,1;addressbackonebyte

stosb;storeainstring

NotFound:

loopScanLoop;loop

outputOutputPrompt

outputTrgtString;outputnewstring

INVOKEExitProcess,0;exitwithreturncode0

PUBLIC_start;makeentrypointpublic

END;endofsourcecode

 

年级

 

班号

 2

 学号

 

专业

 姓名

 

实验

名称

 

实验

类型

设计型

综合型

创新型

*

掌握位指令的使用,尤其注意位指令操作对CF位标识的影响。

 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 教育学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1