最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

《计算机组成原理与汇编语言》Win32考试系统

电脑常识 admin 33浏览 0评论

《计算机组成原理与汇编语言》Win32考试系统

仅供学习参考,自己做出来的才是王道。

目录快查

    • 一、数据类型DataType
    • 二、MASM整数+-*/% IntegerOperation
    • 三、MASM实数+-*/ RealOperation
    • 四、MASM函数Function
    • 五、选择结构SelectionStructure
    • 六、循环结构 LoopStructure
    • 七、C嵌入式汇编 EmbeddedAssembly
    • 八、子程序(函数)
    • 九、递归程序设计 Recursive Programming
    • 十、浮点数表示
    • 十一、CPU与存储器连接CPU
    • 十二、CPU设计与IO系统CPU
    • 十三、校验码 Check Code
    • 十四、考试测试题
      • 循环结构
      • 递归
    • 十五、OD吾爱破解软件

如有错误,请凭正确 截图私聊证实。结课后个人系统数据被清空,无法重新查改验证,请见谅~

一、数据类型DataType

1.键盘输入一个字母,然后输出该字母。
Use the keyboard to input a letter, and then output the letter.
运行后若输入Run the program and input:A B
则结果输出Output the result:'A’ “B”
运行后若输入Run the program and input:a b
则结果输出Output the result:'a’ “b”

.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be included
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
 ;**/
fmt byte '%c %c' ,0
a byte ?
b byte ?
fmt1 byte '"%c"',0
fmt2 byte "'%c' ",0
.code
start:
invoke scanf, addr fmt,addr a,addr b
invoke printf, addr fmt2,dword ptr a
invoke printf, addr fmt1,dword ptr b
 ;**/
invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

2.键盘输入2个整数,然后按相反顺序输出这2个整数。
Use the keyboard to input 2 integers, and then output these 2 integers in reverse order.
运行后若输入Run the program and input:3 4
则结果输出Output the result:4 3
运行后若输入Run the program and input:1 2
则结果输出Output the result:2 1

.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be included
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
 ;**/
fmt byte '%d %d',0
a dword ?
b dword ?
.code
start:
invoke scanf, addr fmt, addr a, addr b
invoke printf, addr fmt, b,a

 ;**/
invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

3.键盘输入2个实数,然后按相反顺序输出这2个实数。
Input 2 real numbers from the keyboard, and then output these 2 real numbers in reverse order.
运行后若输入Run the program and input:3.3 4.45
则结果输出Output the result:4.45 3.3
运行后若输入Run the program and input:1.35 2.4
则结果输出Output the result:2.4 1.35

.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be included
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
 ;**/
fmt byte '%lf %lf',0
a qword ?
b qword ?
fmt1 byte '%g %g',0
.code
start:
invoke scanf, addr fmt, addr a, addr b
invoke printf, addr fmt1, b,a

 ;**/
invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

4.定义结构体商品,含编号、品名、单价、数量,输入一个商品信息求其金额并输出(按“%g”格式输出)。
Define a product structure, including serial number, product name, unit price, and quantity. Enter a product information to find the amount and output (output in “%g” format).
若运行后输入Run the program and input:S001 小刀 4.5 2
则运行结果输出Output the result:编号:S001,品名:小刀,单价:4.5,数量:2,金额:9

.386
.model flat, stdcall
option casemap :none
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib		;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
 ;**/
.data
fmt DB '%s %s %lf %d',0
fmt1 DB '编号:%s,品名:%s,单价:%g,数量:%d,金额:%g',0

Goods struct
no byte 14 DUP(?)
gname byte 20 DUP(?)
cost qword ?
num dword ?
total qword ?
Goods ends
s Goods <>

.code
start:
invoke scanf,addr fmt,addr s.no,addr s.gname ,addr s.cost,addr s.num
FLD s.cost
Fimul s.num
FSTP s.total
invoke printf,addr fmt1, addr s.no,addr s.gname ,s.cost,s.num,s.total

invoke ExitProcess,0
end start
 ;**/

二、MASM整数±*/% IntegerOperation

1.键盘输入整数x、y、z的值,求如下表达式的值:
Enter the values of integers x, y, and z from the keyboard, and obtain the value of the following expression:
x*y+x%y-z
运行后若输入Run the program and input:8 4 2
则结果输出Output the result:8*4+8%4-2=30

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
fmt DB '%d %d %d',0
x dword ?
y dword ?
z dword ?
a dword ?
b dword ?
d dword ?
e dword ?
fmt1 DB '%d*%d+%d%%%d-%d=%d',0
.code
start:
invoke scanf, addr fmt, addr x, addr y, addr z

MOV EAX,x
IMUL y
MOV a,EAX

MOV EAX,x
CDQ
IDIV y
MOV b,EDX

MOV EAX,a
ADD EAX,b
MOV d,EAX

MOV EAX,d
SUB EAX,z
MOV e,EAX
invoke printf, addr fmt1,x,y,x,y,z,e 

invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

 ;**/

2.键盘输入整数x、y、z的值,求如下表达式的值:
Enter the values of integers x, y, and z from the keyboard, and obtain the value of the following expression:
x*y+x/y-z
运行后若输入Run the program and input:8 4 2
则结果输出Output the result:8*4+8/4-2=32

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
fmt DB '%d %d %d',0
x dword ?
y dword ?
z dword ?
a dword ?
b dword ?
d dword ?
e dword ?
fmt1 DB '%d*%d+%d/%d-%d=%d',0
.code
start:
invoke scanf, addr fmt, addr x, addr y, addr z

MOV EAX,x
IMUL y
MOV a,EAX

MOV EAX,x
CDQ
IDIV y
MOV b,EAX

MOV EAX,a
ADD EAX,b
MOV d,EAX

MOV EAX,d
SUB EAX,z
MOV e,EAX
invoke printf, addr fmt1,x,y,x,y,z,e 

invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

 ;**/

3.输入两个小写字母,然后输出其相应的大写字母。
Enter two lowercase letters, and then output their corresponding uppercase letters.
运行后输入Run the program and input:
a b
则结果输出Output the result:
A B

.386				;选择的处理器
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明
.data				;⑤数据段
 ;**/
fmt byte '%c %c',0
a byte ?
b byte ?
.code
start:
invoke scanf, addr fmt, addr a, addr b
sub a,32
sub b,32
invoke printf, addr fmt, dword ptr a, dword ptr b
 ;**/
invoke	ExitProcess,0		;退出进程,返回值为0
end start
/***asm***/

三、MASM实数±*/ RealOperation

1.键盘输入实数x、y、z的值,求如下表达式的值(数值结果用%g格式输出):
Enter the values of real numbers x, y, and z from the keyboard, and obtain the value of the following expression (the numerical result is output in %g format):
x*y+x/y-z
运行后若输入Run the program and input:7.0 4.0 2.0
则结果输出Output the result:7×4+7/4-2=27.75
(编辑格式限制:实际“×”要用星号)

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
fmt byte '%lf %lf %lf',0
x qword ?
y qword ?
z qword ?
a qword ?
b qword ?
d qword ?
e qword ?
fmt1 byte '%g*%g+%g/%g-%g=%g',0
.code
start:
invoke scanf, addr fmt, addr x, addr y,addr z

FLD x
FMUL y
FSTP a

FLD x
FDIV y
FSTP b

FLD a
FADD b
FSTP d

FLD d
FSUB z
FSTP e

invoke printf, addr fmt1,x,y,x,y,z,e
invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

 ;**/

四、MASM函数Function

1.键盘输入实数x的值,求如下表达式的值(保留2位小数):
Enter the value of the real number x from the keyboard, and obtain the value of the following expression (retaining 2 decimal places):

运行后若输入Run the program and input:0.5
则结果输出Output the result:0.65

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype

.data				;⑤数据段 data segment
fmt byte '%lf',0
x qword ?
y qword ?
z qword ?
a qword 2.0
b qword ?
d qword ?
e qword ?
f qword ?
fmt1 byte '%.2lf',0

.code
start:
invoke scanf, addr fmt, addr x

FLD x
FMUL x
FSTP y

FLD x
Fsin
FSTP z

FLD x
Fcos
FSTP b

FLD a
FADD b
FSTP d

FLD z
FDIV d
FADD y
FSTP e

FLD e
Fsqrt 
FSTP f

invoke printf, addr fmt1,f

invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

 ;**/

2.已知机器人当前的位置为(0,0),若该机器人的下一个位置为(x,y),请计算该机器人前进的方向角(角度)。输入x和y值,用反正切函数指令(FPATAN)求角度。
It is known that the current position of the robot is (0,0). If the next position of the robot is (x,y), please calculate the direction angle (angle) of the robot. Enter the x and y values, and use the arctangent function command (FPATAN) to obtain the angle.
运行后若输入Run the program and input:1.0 1.0
则结果输出Output the result:45
运行后若输入Run the program and input:-1.0 1.0
则结果输出Output the result:135
运行后若输入Run the program and input:1.0 -1.0
则结果输出Output the result:-45
运行后若输入Run the program and input:-1.0 -1.0
则结果输出Output the result:-135

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype

.data				;⑤数据段 data segment
fmt byte '%lf %lf',0
x qword ?
y qword ?
z qword ?
a qword 180.0
b qword 3.1415926
d qword ?
fmt1 byte '%g',0

.code
start:
invoke scanf, addr fmt, addr x,addr y

FLD y
FLD x
Fpatan
FSTP z

FLD z
FMUL a
FDIV b
FSTP d

invoke printf, addr fmt1,d

invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start
 ;**/

3.键盘输入实数y和实数x的值,求q=ylg(x)的值(用%g格式显示):
Input the value of real number y and real number x with the keyboard, and find the value of q=ylg(x) (displayed in %g format):
运行后若输入Run the program and input:0.5 10
则结果输出Output the result:0.5
运行后若输入Run the program and input:1.5 0.1
则结果输出Output the result:-1.5

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype

.data				;⑤数据段 data segment
fmt byte '%lf %lf',0
x qword ?
y qword ?
a qword ?
b qword 10.0
d qword ?
q qword ?
fmt1 byte '%g',0

.code
start:
invoke scanf, addr fmt, addr y,addr x

fld y
fld x
fyl2x
Fdiv y
fstp a

fld y
fld b
fyl2x
Fdiv y
fstp d

FLD a
Fdiv d
Fmul y
Fstp q

invoke printf, addr fmt1,q

invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start
 ;**/

4.键盘输入实数q,求实数q的整数部分n和小数部分p并输出(用%g格式输出):
Input the real number q from the keyboard, obtain the integer part n and the decimal part p of the real number q and output (output in %g format):
运行后若输入Run the program and input:4.0
则结果输出Output the result:4 0
运行后若输入Run the program and input:4.1
则结果输出Output the result:4 0.1
运行后若输入Run the program and input:4.9
则结果输出Output the result:4 0.9
运行后若输入Run the program and input:-4.0
则结果输出Output the result:-4 -0
运行后若输入Run the program and input:-4.1
则结果输出Output the result:-4 -0.1
运行后若输入Run the program and input:-4.9
则结果输出Output the result:-4 -0.9

 ;**/
.386			
.model flat, stdcall	
option casemap:none		
include	kernel32.inc
includelib	kernel32.lib
includelib	msvcrt.lib	
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg

.data			
fmt byte '%lf',0
q qword ?
n qword ?
p qword ?
a qword 1.0
fmt1 byte '%g %g',0

.code
start:
invoke scanf, addr fmt, addr q

FLD a
FLD q
Fprem
FSTP p
FSTP a

FLD q
Fsub p
FSTP n

invoke printf, addr fmt1,n,p

invoke	ExitProcess,0	
end start
 ;**/

5.键盘输入实数p(p介于-1~1之间)的值,求v=2^p的值(保留3位小数):
Use the keyboard to input the value of the real number p (p is between -1 and 1), and obtain the value of v=2p (retain 3 decimal places):
运行后若输入Run the program and input:0.5
则结果输出Output the result:1.414
运行后若输入Run the program and input:1
则结果输出Output the result:2.000
运行后若输入Run the program and input:-1
则结果输出Output the result:0.500

 ;**/
.386			
.model flat, stdcall	
option casemap:none		
include	kernel32.inc
includelib	kernel32.lib
includelib	msvcrt.lib	
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg

.data			
fmt byte '%lf',0
v qword ?
p qword ?
q qword ?
a qword 1.0
fmt1 byte '%.3lf',0

.code
start:
invoke scanf, addr fmt, addr p

FLD p
F2xm1
Fadd a
FSTP v

invoke printf, addr fmt1,v

invoke	ExitProcess,0	
end start
 ;**/

6.键盘输入实数v和整数n的值,求w=v×(2^n)的值:
Enter the value of the real number v and the integer n with the keyboard, and obtain the value of w=v*2n:
运行后若输入Run the program and input:1.5 3
则结果输出Output the result:1.5×2^3=12

 ;**/
.386			
.model flat, stdcall	
option casemap:none		
include	kernel32.inc
includelib	kernel32.lib
includelib	msvcrt.lib	
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg

.data			
fmt byte '%lf %lf',0
v qword ?
n qword ?
w qword ?
fmt1 byte '%g*2^%g=%g',0

.code
start:
invoke scanf, addr fmt, addr v,addr n

FLD n
FLD v
Fscale
Fstp w
Fstp n

invoke printf, addr fmt1,v,n,w

invoke	ExitProcess,0	
end start
 ;**/

7.键盘输入实数x和实数y的值,求w=x^y的值(保留2位小数)。
Input the value of real number x and real number y with the keyboard, and find the value of w=xy (retaining 2 decimal places).
提示 Hint:

先求指数 q=y*(以2为底x的对数),再求出q的整数n和小数p,然后求v=2的p次方,最后求w=v*(2^n)。
First find the exponent , then get the values of n and decimal p of q, then find v=2p, and finally get w=v*(2^n).
运行后若输入Run the program and input:0.5 2
则结果输出Output the result:0.25
运行后若输入Run the program and input:4 2
则结果输出Output the result:16.00

 ;**/
.386			
.model flat, stdcall	
option casemap:none		
include	kernel32.inc
includelib	kernel32.lib
includelib	msvcrt.lib	
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg

.data			
fmt byte '%lf %lf',0
x qword ?
y qword ?
z qword 1.0
q qword ?
p qword ?
n qword ?
v qword ?
w qword ?
fmt1 byte '%.2lf',0

.code
start:
invoke scanf, addr fmt, addr x,addr y

FLD y  ;求q
FLD x
FYL2X
FSTP q

FLD z  ;取余得小数p
FLD q
FPREM
FSTP p
FSTP z

FLD q  ;整数n
FLD z
FSCALE
FSTP n
FSTP q

FLD p  ;求v
F2XM1
FADD z
FSTP v

FLD v  ;结果w
FMUL n
FSTP w
invoke printf, addr fmt1,w

invoke	ExitProcess,0	
end start
 ;**/

五、选择结构SelectionStructure

1.输入一个整数,用.IF语句判断能否被3,5,7整除。具体情况如下:
1.若同时能被3,5,7整除输出357;
2.若同时能被3,5整除输出35;
3.若同时能被3,7整除输出37;
4.若同时能被5,7整除输出57;
5.若只能被3整除输出3;
6.若只能被5整除输出5;
7.若只能被7整除输出7;
8.若都不整除,则不输出信息。
Enter an integer and use the .IF statement to determine whether it can be divisible by 3, 5, and 7. Details are as follows:

  1. If it can be divisible by 3, 5, and 7 at the same time, output 357;
  2. If it can be divisible by 3 and 5 at the same time, output 35;
  3. If it can be divisible by 3 and 7 at the same time, output 37;
  4. If it can be divisible by 5 and 7 at the same time, output 57;
  5. If it can only be divisible by 3, output 3;
  6. If it can only be divisible by 5, output 5;
  7. If it can only be divisible by 7 and output 7;
  8. If it is not divisible, no information will be output.
    运行后输入Run the program and input:
    105
    则结果输出Output the result:
    357
    运行后输入:
    15
    则结果输出Output the result:
    35
    运行后输入:
    14
    则结果输出Output the result:
    7
    运行后输入:
    121
    则结果输出Output the result:
    (没有输出)
.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段
 ;**/
fmt byte '%d',0
x dword ?
a dword ?
b dword ?
d dword ?
l dword 3
m dword 5
n dword 7
fmt1 byte '3',0
fmt2 byte '5',0
fmt3 byte '7',0

.code
start:
invoke scanf, addr fmt, addr x
mov eax,x
cdq
idiv l
mov a,edx

mov eax,x
cdq
idiv m
mov b,edx

mov eax,x
cdq
idiv n
mov d,edx

.if a==0
   invoke printf, addr fmt1
.endif
.if b==0
   invoke printf, addr fmt2
.endif
.if d==0
   invoke printf, addr fmt3
.endif


 ;**/
invoke ExitProcess,0		;⑨退出进程,返回值为0
end	start					;⑩指明程序入口点start

2.用.IF….ELSEIF伪指令实现输入一个分数(0~100的整数),输出相应的成绩等级。
分数与成绩等级对应关系分别为90-100分为优秀,80-89为良好,70-79为中,60-69为及格,0-59为不及格。
Use the .IF…ELSEIF pseudo-instruction to input a score (an integer from 0 to 100) and output the corresponding grade. The corresponding relationship between scores and grades is 90 to 100 for excellent(优秀), 80 to 89 for good(良好), 70 to 79 for medium(中), 60 to 69 for passing(及格), and 0 to 59 for failing(不及格).
运行后若输入Run the program and input:95
则结果输出Output the result:优秀
运行后若输入Run the program and input:86
则结果输出Output the result:良好
运行后若输入Run the program and input:73
则结果输出Output the result:
运行后若输入Run the program and input:66
则结果输出Output the result:及格
运行后若输入Run the program and input:53
则结果输出Output the result:不及格

.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段
 ;**/
fmt byte '%d',0
x sdword ?
fmt1 byte '优秀',0
fmt2 byte '良好',0
fmt3 byte '中',0
fmt4 byte '及格',0
fmt5 byte '不及格',0

.code
start:
invoke scanf, addr fmt, addr x

.if x>=90 && x<=100
   invoke printf, addr fmt1

.elseif x>=80 && x<=89
   invoke printf, addr fmt2
.elseif x>=70 && x<=79
   invoke printf, addr fmt3
.elseif x>=60 && x<=69
   invoke printf, addr fmt4
.else
   invoke printf, addr fmt5
.endif
 ;**/
invoke ExitProcess,0		;⑨退出进程,返回值为0
end	start					;⑩指明程序入口点start

3.编写一段程序,用.IF语句(不用jcc指令)完成下面计算公式,其中:变量x和y都是整数类型。

运行后若输入Run the program and input:-4
则结果输出Output the result:-4
运行后若输入Run the program and input:4
则结果输出Output the result:16
运行后若输入Run the program and input:22
则结果输出Output the result:66

 ;**/
.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段

fmt byte '%d',0
x sdword ?
y sdword ?
a dword 3

.code
start:
invoke scanf, addr fmt, addr x

.if x<=0
   invoke printf, addr fmt,x
.endif

.if x>0 && x<10
mov eax,x
Imul eax,x
mov y,eax
invoke printf, addr fmt,y
.endif

.if x>=10
mov eax,x
Imul eax,a
mov y,eax
invoke printf, addr fmt,y
.endif

invoke ExitProcess,0		;⑨退出进程,返回值为0
end	start					;⑩指明程序入口点start


 ;**/

4.编写一段程序,用jcc指令(不用.IF语句)完成下面计算公式,其中:变量x和y都是整数类型。

运行后若输入Run the program and input:-4
则结果输出Output the result:-4
运行后若输入Run the program and input:4
则结果输出Output the result:16
运行后若输入Run the program and input:22
则结果输出Output the result:66

 ;**/
.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段

fmt byte '%d',0
x sdword ?
y sdword ?
a dword 3

.code
start:
invoke scanf, addr fmt, addr x
cmp x,0
JLE LE0

cmp x,10
JL L10
  mov eax,x
  Imul a
  mov y,eax
jmp done

L10:
mov eax,x
Imul x
mov y,eax
jmp done

LE0:
mov eax,x
mov y,eax
done:
invoke printf, addr fmt , y
invoke ExitProcess,0		;⑨退出进程,返回值为0
end	start					;⑩指明程序入口点start
 ;**/

5.编写程序,完成下面计算公式,其中:变量x和y都是REAL8类型,结果保留2位小数。

;**/
.386			
.model flat, stdcall	
option casemap:none		
include	kernel32.inc
includelib	kernel32.lib
includelib	msvcrt.lib	
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg

.data
fmt byte '%lf',0
x qword ?
y qword ?
a qword 2.0
b qword -1.9
d qword 1.5
fmt1 byte '%.2lf',0

.code
start:
invoke scanf, addr fmt, addr x
FEQU=40H
FLESS=1
FLD x
FCOMP b
fnstsw ax

.IF ah&FLESS          ;<-1.9
FLD x ;sinx
Fsin
FSTP y

.ELSE                      ;>=-1.9
   FLD x
   FCOMP d
   fnstsw ax
   .IF ah&(FLESS or FEQU) ;<=1.5
      FLD x ;2x
      Fmul a
      FSTP y

    .ELSE ;>1.5
         FLD x ;cosx
         Fcos
         FSTP y
   .ENDIF
.ENDIF
invoke printf, addr fmt1,y
invoke	ExitProcess,0	
end start

 ;**/

六、循环结构 LoopStructure

1.输入若干整数,统计正数与负数和。
运行后若输入Run the program and input:1 -2 3 -4
则结果输出Output the result:正数和为:4 负数和为:-6

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
szFmt  	BYTE	'正数和为:%d 负数和为:%d',0
 ;**/
fmt byte '%d',0
n sdword ?
s sdword 0
s1 sdword 0

.code
start:
invoke scanf, addr fmt,addr n
.while eax==1
  .if n>=0
    mov ebx,s
    add ebx,n
    mov s,ebx
  .else
    mov ebx,s1
    add ebx,n
    mov s1,ebx
  .endif
invoke scanf, addr fmt,addr n
.endw
invoke printf, addr szFmt, s,s1
ret
 ;**/

2.编写求1+2+3+…+n和的程序(整数n由键盘输入且n>1)。
运行后若输入Run the program and input:10
则结果输出Output the result:1+…+10=55
运行后若输入Run the program and input:100
则结果输出Output the result:1+…+100=5050

 ;**/
.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明

.data				;⑤数据段
fmt DB '%d',0
n dword ?
fmt1 DB '1+...+%d=%d',0

.code
start:
invoke scanf, addr fmt,addr n
mov ecx,1;累加和,初始化为0
mov eax,0;循环次数寄存器赋值
.while ecx<=n;循环控制           
   add eax,ecx
      inc ecx                
.endw
invoke printf, addr fmt1, n, eax

ret;invoke ExitProcess,0
end start 

 ;**/

3.键盘输入若干对整数x、y,求其相应的最大公约数。
运行后若输入Run the program and input:
18 12
8 12
10 12

则结果输出Output the result:
6
4
2

 ;**/
.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段

fmt byte '%d %d',0
x dword ?
y dword ?
a dword ?
b dword ?
d dword ?
fmt1 byte '%d',13,10,0

.code
start:
invoke scanf, addr fmt,addr x,addr y

.while eax==2
  mov eax,x
  .if eax<y ;除数与被除数交换
    mov eax,x
    xchg eax,y
    mov  x,eax
  .endif

  mov eax,x
  cdq
  div y;余数在edx,商在eax

  .if edx==0;余数为0,该除数即为最大公约数
    mov eax,y
    mov a,eax
  .endif

  mov eax,y
  .while edx!=0
    mov a,edx
    cdq
    div a
    mov eax,a
  .endw
invoke printf, addr fmt1, a
invoke scanf, addr fmt,addr x,addr y
.endw

ret
end start 

 ;**/

4.键盘输入若干对实数x、y,求各对实数乘积和。
运行后若输入Run the program and input:
2.5 2
1.5 4
2.2 2

则结果输出Output the result:
15.4

 ;**/
.386
.model flat, stdcall
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib				;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
option casemap :none 

.data
fmt DB '%lf %lf',0
fmt1 DB '%g',0
x qword ?
y qword ?
s qword ?
s1 qword ?

.code
start:
Fld s1
invoke scanf, addr fmt, addr x, addr y

.while EAX==2 ;读取2个数据
Fld x
Fmul y
Fstp s
Fadd s
invoke scanf, addr fmt, addr x, addr y
.endw
Fstp s1

invoke printf, addr fmt1, s1

invoke ExitProcess,0
end start
 ;**/

5.键盘输入一串字符(最多80个字符),输出其中的数字。
运行后若输入Run the program and input:ab4du5jkf8
则结果输出Output the result:458

 ;**/
.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段

n dword ?
s db 80 Dup(0)
fmt db '%s',0
fmt1 db '%c',0

.code
start:
invoke scanf, addr fmt,addr s
mov esi,0

.while s[esi]!=0
    .if s[esi]>='0' && s[esi]<='9'
        invoke printf, addr fmt1,dword ptr s[esi]
    .endif
    inc esi
.endw
invoke printf, addr fmt1,n

ret
end start
 ;**/

6.统计对角线元素之和并输出。以下程序运行后,首先输入一个小于10的整数n,然后输入n行n列的整数矩阵,最后统计对角线元素(行列下标值相等或行列下标值之和等于n-1)之和并输出。
运行后若输入Run the program and input:
5
9 8 6 4 2
1 2 3 4 5
6 7 8 9 3
0 9 8 7 6
5 4 3 2 1

则结果输出Output the result:
47

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
fmt  	BYTE	'%d',0
Sum    DWORD 0
n      DWORD ?
Arr    DWORD 10 DUP(10 DUP (?))
.code
start:
invoke scanf,addr fmt,addr n
MOV ESI,0;行下标i初值
MOV EBX,0;存每行起始地址
.WHILE ESI<n
MOV EDI,0;列下标j初值
.WHILE EDI<n
pushA;调用函数之前所有寄存器入栈保护起来
invoke scanf,addr fmt,addr Arr[EBX+EDI*4]
popA;调用函数之后所有寄存器出栈恢复为原值
INC EDI
.ENDW
INC ESI
MOV EAX,n
SHL EAX,2;EAX=n*4,左移2位相当于*22
LEA EBX,[EBX+EAX];每循环一次EBX+=n*4
.ENDW
 ;**/
mov esi,0
mov ebx,0
.while esi<n
   mov edi,0
   .while edi<n
      MOV EAX,ESI
      ADD EAX,EDI
      ADD EAX,1
      .IF ESI==EDI||EAX==n
         MOV ECX,Sum
         ADD ECX,Arr[EBX+EDI*4]
         MOV Sum,ECX
      .ENDIF
      INC EDI
   .ENDW
   INC ESI
   MOV EAX,n
   SHL EAX,2    
   LEA EBX,[EBX+EAX]
.ENDW
 ;**/
invoke printf,addr fmt,Sum
ret
end start 

7.键盘输入若干对整数x、y,求其相应的最小公倍数。
运行后若输入Run the program and input:
18 12
8 12
10 12

则结果输出Output the result:
36
24
60

.386
.model flat, stdcall
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib				;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
option casemap :none 
 ;**/
.data				;⑤数据段

fmt byte '%d %d',0
x dword ?
y dword ?
a dword ?
b dword ?
d dword ?
fmt1 byte '%d',13,10,0

.code
start:
invoke scanf, addr fmt,addr x,addr y

.while eax==2
  mov eax,x
  .if eax<y ;除数与被除数交换
    mov eax,x
    xchg eax,y
    mov  x,eax
  .endif

  mov eax,x
  cdq
  div y;余数在edx,商在eax

  .if edx==0;余数为0,该除数即为最大公约数
    mov eax,y
    mov a,eax
  .endif

  mov eax,y
  .while edx!=0
    mov a,edx
    cdq
    div a
    mov eax,a
  .endw
    mov eax,x
    imul y
    cdq
    div a
    mov b,eax
invoke printf, addr fmt1, b
invoke scanf, addr fmt,addr x,addr y
.endw

ret
end start 
 ;**/

8.键盘输入若干实数,求其和。
运行后若输入Run the program and input:
1.2 2.3 3.4
则结果输出Output the result:
6.9

.386
.model flat, stdcall
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib				;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
option casemap :none 
 ;**/
.data
fmt DB '%lf',0
fmt1 DB '%g',0
x qword ?
s qword 0.0

.code
start:
Fld s
invoke scanf, addr fmt, addr x

.while EAX==1
Fadd x
invoke scanf, addr fmt, addr x
.endw

Fstp s
invoke printf, addr fmt1, s
invoke ExitProcess,0
end start

 ;**/

9.键盘输入若干个复数,分别求其模,最后再求所有模之和并显示(保留1位小数)。

运行后若输入Run the program and input:
3.0 4.0
1.0 1.0
6.0 8.0

则结果输出Output the result:
16.4

.386
.model flat, stdcall
option casemap :none 
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib				;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
 ;**/
.data
fmt DB '%lf %lf',0
fmt1 DB '%.1lf',0
x qword ?
y qword ?
a qword ?
s qword ?
s1 qword ?

.code
start:
Fld s1
invoke scanf, addr fmt, addr x, addr y

.while EAX==2 ;读取2个数据
Fld x
Fmul x
Fstp a

Fld y
Fmul y
Fadd a
Fsqrt
Fstp s

Fadd s

invoke scanf, addr fmt, addr x, addr y
.endw
Fstp s1

invoke printf, addr fmt1, s1

invoke ExitProcess,0
end start
 ;**/

10.键盘输入正整数n,编程求1到正整数n之间的所有奇数之和并输出。
运行后若输入Run the program and input:5
则结果输出Output the result:1到5的奇数和为9
运行后若输入Run the program and input:10
则结果输出Output the result:1到10的奇数和为25

.386
.model flat, stdcall
option casemap :none
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib		;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
 ;**/
.data				;⑤数据段
fmt DB '%d',0
n dword ?
s dword 1
fmt1 DB '1到%d的奇数和为%d',0

.code
start:
invoke scanf, addr fmt,addr n
mov ecx,1
mov eax,0
.while ecx<=n          
   add eax,ecx
   inc ecx
   inc ecx
.endw
invoke printf, addr fmt1, n, eax

ret;invoke ExitProcess,0
end start 

 ;**/

11.编程求若干字符串的长度(字符串以0作为结束标志)。
运行后若输入:
abc
则结果输出:
3
运行后若输入:
abcdef abc
则结果输出:
6
3

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
 ;**/
s db 80 Dup(0)
fmt db '%s',0
fmt1 db '%d',13,10,0

.code
start:
invoke scanf, addr fmt,addr s
.while eax==1
  mov edi,0
  .while s[edi]!=0
    inc edi
  .endw
invoke printf, addr fmt1,edi
invoke scanf,  addr fmt,addr s
.endw
ret
end start
 ;**/

12.输入一个字符和一个不含空格的字符串,统计该字符在字符串中出现的次数。
运行后输入:
s Thisisateststring
则结果输出:
'Thisisateststring’中有4个’s’字符
运行后输入:
h This
则结果输出:
'This’中有1个’h’字符

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明
.data				;数据段
 ;**/
x DB ?
s DB 80 DUP(0)
num dword 0
fmt DB '%c %s',0
fmt1 DB '''%s''中有%d个''%c''字符',0

.code
start:
invoke scanf, addr fmt, addr x, addr s
mov edi,0
mov esi,0
mov al,x
.while s[edi]!=0
   mov ah,s[edi]
   .if ah==al
      inc esi
   .endif
   inc edi
.endw
mov num,esi
invoke printf, addr fmt1,addr s, num, dword ptr x

 ;**/
invoke ExitProcess,0		
end	start		

七、C嵌入式汇编 EmbeddedAssembly

1.键盘输入整数x、y、z,然后输出x*y+z的值。
Keyboard input integers x, y, z, and then output the value of x*y+z.
运行后若输入Run the program and input:3 4 5
则结果输出Output the result:3*4+5=17

#include "stdio.h"
void main()
{
	int x,y,z,t;
	scanf("%d %d %d",&x,&y,&z);
	__asm
	{
/*【*/
mov eax,x
mul y
add eax,z
mov t,eax

/*】*/
	}
	printf("%d*%d+%d=%d",x,y,z,t);
}

2.键盘输入任一个字符,然后以此字符填充数组a[41]。
Input any character on the keyboard, and then fill the array a[41] with this character.
注意:填充40个字符即可。Note: Just fill in 40 characters.
如 For example:
运行后输入Run the program and input:A
则结果输出Output the result:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

#include "stdio.h"
void main()
{
char a[41]={0},c;
scanf("%c",&c );
	__asm
	{
/*【*/
mov al,c
lea edi,a
mov ecx,40
again:
stosb
loop again

/*】*/
	}
	printf("%s",a);
}

3.键盘输入任一个整数n和一个汉字(即两个字符),然后以此汉字填充p指定位置。
注意:最多填充40个汉字(n<=40)。

Input any integer n and a Chinese character (that is, two characters) on the keyboard, and then fill the designated position of p with this Chinese character.
Note: Fill up to 40 Chinese characters (n<=40).
如 For example:
运行后输入Run the program and input:4 字
则结果输出Output the result:字字字字

#include "stdio.h"
void main()
{
char c1,c2,p[81]={0};
int n;
scanf("%d %c%c",&n,&c1,&c2);
	__asm
	{
/*【*/

cld
lea edi,p
mov al,c1
mov ah,c2
mov ecx,n
rep stosw

/*】*/
	}
	printf("%s",p);
}

4.键盘输入一串字符给数组a,然后请你将其复制到数组b。
The keyboard enters a string of characters into array a, and then asks you to copy it to array b.
如 For example:
运行后输入Run the program and input:ABCDEFG
则结果输出Output the result:ABCDEFG

#include "stdio.h"
void main()
{
char a[80],b[80];
scanf("%s",a);
	__asm
	{
/*【*/
lea esi,a
lea edi,b
mov ecx,80
rep movsb

/*】*/
	}
	printf("%s",b);
}

5.将字符数组a[63]中的数字删除(相当于把字母移到起始位置)。
注意:字符串结束标志也移。

Delete the number in the character array a[63] (equivalent to moving the letter to the starting position).
Note: The end of the string is also moved.
如 For example:
运行后输入Run the program and input:null(不输入)
则结果输出Output the result:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

#include "stdio.h"
void main()
{
char a[63]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	__asm
	{
/*【*/
cld
lea esi,a+10
lea edi,a
mov ecx,53
rep movsb
/*】*/
	}
	printf("%s",a);
}

6.将字符数组a[63]中的字母向后移10个位置。
注意:前10个位置字母不变。

Move the letters in the character array a[63] back 10 positions.
Note: The first 10 position letters remain unchanged.
如 For example:
运行后输入Run the program and input:null(不输入)
则结果输出Output the result:ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

#include "stdio.h"
void main()
{
char a[63]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",c;
	__asm
	{
/*【*/
std
lea esi,a+51
lea edi,a+61
mov ecx,52
rep movsb
cld
/*】*/
	}
	printf("%s",a);
}

7.输入两字符串,编程判断两字符串是否相等。
Input two character-strings and program to judge whether the two character-strings are equal.
运行后输入Run the program and input:abcd abcdef
则结果输出Output the result:不相等
运行后输入Run the program and input:abcdef abcd
则结果输出Output the result:不相等
运行后输入Run the program and input:abcd abcd
则结果输出Output the result:相等

#include "stdio.h"
void main()
{
char S[80],D[80];
int flag=1;//预设flag标记,默认相等
scanf("%s %s",S,D);
	__asm
	{
/*【*/
cld
mov al,0
lea edi,S
mov ecx,80
repne scasb
lea eax,S
Sub edi,eax
mov ecx,edi
lea esi,S
lea edi,D
repe cmpsb

jz done
mov flag,0
done:

/*】*/
	}
	if(flag==0)
	  printf("不相等"); 
	else
	 printf("相等");
}

8.键盘输入一串字符给数组a和一个整数i,然后将字符串a中的字符向后移i个位置。
注意:前i个位置字符不变。

如:
运行后输入:ABCDEFGHIJKLMNOPQRSTUVWXYZ 10
则结果输出:ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ

#include "stdio.h"
void main()
{
char a[63];
int i;
scanf("%s %d",a,&i);
__asm
{
/*【*/
STD
lea esi,a+61
sub esi,i
lea edi,a+61
mov ecx,62
sub ecx,i
rep movsb
CLD

/*】*/
}
printf("%s",a);
}

9.键盘输入a和b两串字符,编程实现将a串和b串连接的结果存入字符数组c[50]并输出。
如:
运行后输入:ABCD abcd
则结果输出:ABCDabcd

#include "stdio.h"
#include "string.h"
void main()
{
char a[50]="ABCD",b[50]="abcd", c[50]={0};
int n,m;
scanf("%s %s",a,b);
n=strlen(a);m=strlen(b);
	__asm
	{
/*【*/
lea esi,a
lea edi,c
mov ecx,n
rep movsb

lea esi,b
lea edi,c
add edi,n
mov ecx,m
rep movsb

/*】*/
	}
	printf("%s",c);
}

10.键盘输入任一个整数n和一个汉字(即两个字符),然后用2n个汉字填充数组s[81]。
Input any integer n and one Chinese character (that is, one Chinese character occupies two characters) from the keyboard, and then fill the array s[81] with 2 times n Chinese characters.
如For example:
运行后输入After running, input:4 字
则结果输出Then output:字字字字字字字字

#include "stdio.h"
void main()
{
char a,b,s[81]={0};
int n;
scanf("%d %c%c",&n,&a,&b);
__asm
{
/*【*/
Cld
lea edi,s
mov al,a
mov ah,b
mov ecx,n
sal ecx,1
rep stosw
/*】*/
}
printf("%s",s);
}

11.键盘输入任一个整数n和一个两字词语(即4个字符),然后用2n个词语填充数组s[81]。
Input any integer n and a two-character Chinese words (occupying 4 characters) from the keyboard, and then fill the array s[81] with 2 times n Chinese words.
如For example:
运行后输入After running, input:4 汉字
则结果输出Then output:汉字汉字汉字汉字汉字汉字汉字汉字

#include "stdio.h"
void main()
{
char a,b,c,d,s[81]={0};
int n;
scanf("%d %c%c%c%c",&n,&a,&b,&c,&d);
__asm
{
/*【*/
Cld
lea edi,s
mov ecx,n
imul ecx,4
mov esi,0
mov ebx,2

again:
mov eax,esi
cdq
idiv ebx
cmp edx,0
JE Tag
mov al,c
mov ah,d
stosw
JMP DONE

Tag:
mov al,a
mov ah,b
stosw

DONE:
inc esi
LOOP again
/*】*/
}
printf("%s",s);
}

八、子程序(函数)

1.编一函数Max(int x,int y)用于求整数x和y中的最大值。
Write a function Max (int x, int y) to find the maximum value of integers x and y.
运行后输入Run the program and input:
4 5
则结果输出Output the result:
最大值为5
运行后输入Run the program and input:
5 4
则结果输出Output the result:
最大值为5

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
fmt	BYTE	'%d %d',0		;定义变量
fmt2	BYTE	'最大值为%d',0		;定义变量
x	DWORD	?
y	DWORD	?
.code				;⑥代码段
 ;**/
Max proc a:dword,b:dword
mov eax,a
.if eax<b
      mov eax,b
.endif
ret
Max endp

 ;**/
start:				;定义标号start
invoke scanf,ADDR fmt,ADDR x,ADDR y	;输入x和y的值
invoke Max,x,y
invoke printf,ADDR fmt2,EAX
RET		;退出
end	start			;指明程序入口点start

2.编一函数fun(int n)用于判断整数n是否是素数。
Write a function fun(int n) to determine whether the integer n is a prime number.
运行后输入Run the program and input:
5
则结果输出Output the result:
是素数
运行后输入Run the program and input:
4
则结果输出Output the result:
不是素数

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
fmt	BYTE	'%d',0		;定义变量
fmt2	BYTE	'%s',0		;定义变量
n	DWORD	0
s1	BYTE	'是素数',0
s2	BYTE	'不是素数',0
.code				;⑥代码段
 ;**/
fun proc a:dword
local x:dword
mov x,2
mov ecx,n

.while x<ecx
    mov eax,n
    cdq
    div x
    .if edx==0
        .break
    .endif
    inc x
.endw

mov ecx,n
.if x<ecx
    invoke printf,addr s2
.else
    invoke printf,addr s1
.endif

ret
fun endp
 ;**/
start:				;定义标号start
invoke scanf,ADDR fmt,ADDR n	;输入n的值
invoke fun,n
RET
end	start			;指明程序入口点start

3.编写一个子程序Upper,实现将小写字母变大写字母(不是小写字母不变)。
Write a subroutine named Upper to change lowercase letters to uppercase letters (leave the uppercase letters unchanged).
运行后输入Run the program and input:
d
则结果输出Output the result:
[d]大写为D
运行后输入Run the program and input:
B
则结果输出Output the result:
[B]大写为B

.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段
Infmt	BYTE	'%c',0		;定义变量
Outfmt	BYTE	'[%c]大写为%c',13,10,0
c1		BYTE	?
.code						;⑥代码段
 ;**/
Upper proc c2:dword
movzx eax,byte ptr c2
.if eax>='a' && eax<='z'
  sub eax,20H
.endif
RET
Upper endP


 ;**/
start:						;定义标号start
invoke scanf,ADDR Infmt,ADDR c1	;输入c1的值
invoke Upper,DWORD PTR c1	;求c1字符的大写通过EAX返回
invoke printf,ADDR Outfmt,DWORD PTR c1,EAX;输出
RET		;退出
end	start					;指明程序入口点start

4.编写子程序,类似C语言int SumN(int a[],int n)函数,求n个元素数组a中整数和并返回这个和。
Write a subroutine, similar to the C language function int SumN(int a[],int n), and obtain the integer sum in the n-element array a and return this sum.
运行后输入Run the program and input:
1 3 5
则结果输出Output the result:
和为9

.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段
a		DWORD	80 Dup(0) 	;定义数组a
Infmt	BYTE	'%d',0
Outfmt	BYTE	'和为%d',0
.code						;⑥代码段
 ;**/
SumN proc s:dword, n:dword
mov esi,0
mov eax,0
mov edx,s
.while esi<n
   add eax,[edx+esi*4]
   inc esi
.endw
RET
SumN endP


 ;**/
start:						;定义标号start
mov		ESI,0
invoke scanf,ADDR Infmt,ADDR a[ESI*4];输入a[i]的值
.while	EAX==1
INC		ESI
invoke scanf,ADDR Infmt,ADDR a[ESI*4];
.endw
invoke SumN,ADDR a,ESI		;求a数组和通过EAX返回
invoke printf,ADDR Outfmt,EAX;输出结果
RET	;退出
end	start					;指明程序入口点start

5.编一函数MinN(int a[],int n)用于求n个元素的数组a中的最小元素。
Write a function MinN(int a[],int n) to find the smallest element in an array a of n elements.
运行后输入Run the program and input:
1 3 4 5 2
则结果输出Output the result:
最小值为1
运行后输入Run the program and input:
7 3 6 4 5 8
则结果输出Output the result:
最小值为3

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
Infmt	BYTE	'%d',0
Outfmt	BYTE	'最小值为%d',0
a		DWORD	80 Dup(0) 	;定义数组a
.code				;⑥代码段
 ;**/
MinN proc x:dword, y:dword

mov esi,0
mov ebx,x
mov eax,[ebx+esi*4]

.while esi<y
      .if [ebx+esi*4]<eax
               mov eax,[ebx+esi*4]
     .endif
      inc esi
.endw

ret
MinN endp
 
 ;**/
start:				;定义标号start
mov		ESI,0
invoke scanf,ADDR Infmt,ADDR a[ESI*4];输入a[i]的值
.while	EAX==1
INC		ESI
invoke scanf,ADDR Infmt,ADDR a[ESI*4];
.endw
invoke MinN,ADDR a,ESI		;求a数组和通过EAX返回
invoke printf,ADDR Outfmt,EAX;输出结果
RET		;退出
end	start			;指明程序入口点start

6.编一串拷贝子程序,实现C语言char strcpy(char Dst,char Src)函数,然后主程序调用strcpy(s1,s2)实现s2串拷贝到s1串。
Write a string-copy subroutine to implement the C language function char
strcpy(char *Dst,char *Src), and then the main program calls strcpy(s1,s2) to copy the content of s2 string to that of the s1 string.
运行后输入Run the program and input:
ABCD
则结果输出Output the result:
ABCD

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
fmt	BYTE	'%s',0		;定义变量
s1	BYTE	80 Dup(0)
s2	BYTE	80 Dup(0)
.code				;⑥代码段
 ;**/
strcpy proc x:dword, y:dword
mov esi, y
mov edi, x    
mov ecx, 80
rep movsb
ret
strcpy endp

 ;**/
start:				;定义标号start
invoke scanf,ADDR fmt,ADDR s2	;输入s2的值
invoke strcpy,ADDR s1,ADDR s2	;求s2串拷贝到s1串
invoke printf,ADDR fmt,ADDR s1	;输出
invoke ExitProcess,0		;退出进程,返回值为0
end	start			;指明程序入口点start

7.编一串连接子程序,实现C语言char strcat(char Dst,char Src)函数,然后主程序调用strcat(s1,s2)实现s2串追加(连接)到s1串。
Write a string- concatenation subroutine to implement the C language function char
strcat (char *Dst, char *Src), and then the main program calls strcat (s1, s2) to implement the addition (concatenation) of the s2 string to the s1 string.
运行后输入Run the program and input:
AB CD
则结果输出Output the result:
ABCD

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
fmt1	BYTE	'%s %s',0	;定义变量
fmt2	BYTE	'%s',0
s1	BYTE	80 Dup(0)
s2	BYTE	80 Dup(0)
.code				;⑥代码段
 ;**/
strcat proc str1:dword, str2:dword
mov esi, str2
mov edi, str1
mov eax,0

.while byte ptr[edi]!=0
      inc edi
.endw
.while byte ptr[esi]!=0
      inc esi
      add eax,1
.endw
CLD
mov esi,str2
mov ecx,eax
rep movsb
ret
strcat endp
 ;**/
start:				;定义标号start
invoke scanf,ADDR fmt1,ADDR s1,ADDR s2
invoke strcat,ADDR s1,ADDR s2	;求s2串连接到s1串
invoke printf,ADDR fmt2,ADDR s1;输出
invoke ExitProcess,0		;退出进程,返回值为0
end	start			;指明程序入口点start

8.编写子程序,类似C语言double MaxREAL(double a[],int n) 函数,求n个元素数组a中的最大值。
Write a subroutine, similar to the C language function double MaxREAL(double a[],int n), to find the maximum value of the n-element array a.
运行后输入Run the program and input:
1.1 3.2 5.2 2.1
则结果输出Output the result:
最大值为5.2

.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段
Infmt	BYTE	'%lf',0
Outfmt	BYTE	'最大值为%g',0
a		QWORD	80 Dup(0.0) 	;定义数组a
MaxR QWORD ?
.code						;⑥代码段
 ;**/
MaxREAL proc s:dword, n:dword

mov edx,s
FLD qword ptr [edx]
FSTP MaxR
mov ecx,n
Fless=1
Fequ=40h

.while ecx>0
      FLD MaxR
      Fcomp qword ptr [edx]
      Fnstsw ax
      .if ah&Fless
            FLD qword ptr [edx]
            FSTP MaxR
      .endif
      add edx,8
      dec ecx
.endw

FLD MaxR

ret
MaxREAL endp
 ;**/
start:						;定义标号start
mov		ESI,0
invoke scanf,ADDR Infmt,ADDR a[ESI*8];输入a[i]的值
.while	EAX==1
INC		ESI
invoke scanf,ADDR Infmt,ADDR a[ESI*8];
.endw
invoke MaxREAL,ADDR a,ESI		;求a数组和通过EAX返回
FSTP MaxR
invoke printf,ADDR Outfmt,MaxR;输出结果
RET	;退出
end	start					;指明程序入口点start

九、递归程序设计 Recursive Programming

1.编一函数fun(int n),用归递方法实现求1到n的累加和,运行后输入Run the program and input正整数n,输出该累加和。
Write a function fun(int n), use the recursive method to implement the cumulative sum of 1 to n, input a positive integer n after running, and output the cumulative sum.
运行后输入Run the program and input:
10
则结果输出Output the result:
55

.386	
.model flat, stdcall
option casemap:none	
includelib	msvcrt.lib
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg	
.data			
fmt	BYTE	'%d',0	
N	DWORD	0
.code	
 ;**/
fun proc n:dword
.if n>1
   mov ecx,n
   dec ecx
   invoke fun, ecx
   add eax,n
.else
   mov eax,n
.endif
ret
fun endp

 ;**/
start:
invoke scanf,ADDR fmt,ADDR N;输入N
invoke fun,N 
invoke printf,addr fmt,eax
ret
end	start

2.用归递方法实现Hanoi(汉诺)塔问题。
Use the recursive method to implement the Hanoi Tower problem.

运行后若输入Run the program and input:
1
则结果输出Output the result:
A->C

运行后若输入Run the program and input:
2
则结果输出Output the result:
A->B
A->C
B->C

运行后若输入Run the program and input:
3
则结果输出Output the result:
A->C
A->B
C->B
A->C
B->A
B->C
A->C

.386
.model flat, stdcall
option casemap :none 
includelib	msvcrt.lib
printf PROTO C:ptr sbyte,:vararg
scanf PROTO C:ptr sbyte,:vararg
.data
fmt db '%d',0
fmt2 db '%c->%c',10,13,0
N dd ?
.code
 ;**/

fun proc n:dword, mark:dword, flag:dword, temp:dword

.if n<=1
     invoke printf, addr fmt2,mark,temp
.else
     mov ecx,n
     dec ecx
     invoke fun ,ecx,mark,temp,flag
     invoke printf, addr fmt2,mark,temp
     mov ecx,n
     dec ecx
     invoke fun ,ecx,flag,mark,temp
.endif

ret
fun endp


 ;**/
start:
invoke scanf,addr fmt,addr N
invoke fun,N,'A','B','C'
ret
end start 

3.设有一棵完全二叉树(该树除最低下一层右侧结点不存在,其它结点都存在),其每个结点的值都是一个字母。该二叉树各结点的值按层(同层的按从左到右的顺序)存储于字符数组B中,如下图字符数组B的值为“ABCDEFGHIJKLMNOPQRST”。
There is a complete binary tree (except that the node on the right side of the lowest level of the tree does not exist, other nodes exist), and the value of each node is a letter. The value of each node of the binary tree is stored in character array B by layer (from left to right in the same layer). The value of character array B in the following figure is “ABCDEFGHIJKLMNOPQRST”.

现要求编程输入字符数组B的值,然后按中序遍历输出各结点的值。
Now it is required to program input the value of character array B, and then traverse and output the value of each node in the middle order.
若运行后若输入Run the program and input:
ABCDEFG
则运行结果输出Output the result:
DBEAFCG

.386
.model flat, stdcall
option casemap :none
includelib	msvcrt.lib
printf PROTO C:ptr sbyte,:vararg
scanf PROTO C:ptr sbyte,:vararg
strlen PROTO C:ptr sbyte
.data
B db 80 dup(?)
fmt db '%s',0
fmt2 db '%c',0
fmt3 db '空二叉树',0
.code
 ;**/
fun proc b, i, n
.if n<=0
    invoke printf,addr fmt3
.else
     mov esi,i
     lea esi,[esi*2+1]
     .if esi<n
         invoke fun, b, esi, n
     .endif
     mov edx,b
     mov esi,i
     invoke printf, addr fmt2, dword ptr [edx+esi]
.endif

mov esi,i
lea esi,[esi*2+2]
.if esi<n
    invoke fun, b, esi, n
.endif
ret 
fun endp


 ;**/
start:
invoke scanf,addr fmt,addr B
invoke strlen,addr B
invoke fun,addr B,0,eax
ret
end start

4.设有一棵二叉树,其每个结点的值都是一个字母。该二叉树各结点的值按层(同层的按从左到右的顺序)存储于字符数组B中,如下图字符数组B的值为“ABCDEFGH^JK^MNOP^^^T”,其中“^”表示不存在的结点。
There is a binary tree, the value of each node is a letter. The value of each node of the binary tree is stored in character array B by layer (from left to right in the same layer). The value of character array B in the following figure is “ABCDEFGHJKMNOP^^^T”, where " ^" indicates a node that does not exist.

现要求编程输入字符数组B的值,然后按中序遍历输出各结点的值。
Now it is required to program input the value of character array B, and then traverse and output the value of each node in the middle order.
若运行后若输入Run the program and input:
ABCD^^G
则运行结果输出Output the result:
DBACG

.386
.model flat, stdcall
option casemap :none
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib		;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
 ;**/
.data
infmt DB '%s',0
outfmt DB '%c',0
s DB 80 Dup(0)
flag DD 0

.code
inorder proc x:dword, len:dword
mov esi,x
.if esi<len
   mov eax,x 
   imul eax,2
   add eax,1
   invoke inorder ,eax,len
   mov esi,x
   .if s[esi]!='^'
      invoke printf,addr outfmt,s[esi]
   .endif
   mov eax,x
   imul eax,2
   add eax,2
   invoke inorder ,eax,len
.endif
ret
inorder endp
start:
invoke scanf,addr infmt,addr s
mov edi,0
.while s[edi]!=0
   inc edi
.endw
invoke inorder ,flag,edi
ret
end start

 ;**/

5.编一函数fun(int n),用归递方法实现将十进制数转换为二进制数,运行后输入Run the program and input正整数n,输出n的二进制数。
Write a function fun(int n), use the recursive method to convert the decimal number into a binary number. After running, enter the positive integer n and the word “Run the program and input”, and output the binary number of n.
运行后输入Run the program and input:
250
则结果输出Output the result:
11111010

.386
.model flat, stdcall
option casemap:none
includelib	msvcrt.lib
scanf PROTO C:DWORD,:vararg
printf PROTO C:DWORD,:vararg
.data
fmt	BYTE	'%d',0
N	DWORD	0
b	DWORD	2
.code
 ;**/
fun proc n
local x:dword,y:dword
mov x,2
.if n<2
   invoke printf, addr fmt,n
.else
   mov eax,n
   cdq
   div x
   mov y,edx
   invoke fun, eax
   invoke printf, addr fmt, y
.endif
ret
fun endp

 ;**/
start:
invoke scanf,ADDR fmt,ADDR N;输入N
invoke fun,N 
ret
end	start

/---------------以下类型题目,答题时不能存在空格-----------------/

十、浮点数表示

  1. 现要将 -13.5 表示成单精度机器数即 k=8,n=23,则该机器数对应尾数符号____B(1位,二进制),该机器数用移码表示的阶码为___________B(8位,二进制),用原码表示的尾数数值为_______________________________________B(23位,二进制)。
//因为 “换头没换衣服” 就直接写结果:
-13.5    1    1000 0010        101 1000000000 0000000000
+7.5     0    1000 0001        111 0000000000 0000000000
+14.5    0    1000 0010        110 1000000000 0000000000
-29.0    1    1000 0011        110 1000000000 0000000000
+28.0    0    1000 0011        110 0000000000 0000000000
-26.0    1    1000 0011        101 0000000000 0000000000

2.现要将 +29 表示成单精度机器数即 k=8,n=23,则该机器数对应的尾数符号为____B(1,二),该机器数对应的尾数真值(含符号)为______D(十),实际存储的尾数数值(不含符号)为_______D(十),用原码表示的尾数数值为___________________________B(23,二),该机器数用移码表示的阶码为___________B(8,二),该机器数对应的十六进制数值为__________H。

//答案在此
0    +1.8125    0.8125        110 1000000000 0000000000        1000 0011        41e80000
//因为 “换头没换衣服” 就直接写结果:
+250    +1.5625    0.5625      100 1000000000 0000000000        1000 0011        41c80000
+2640    +1.03125   0.03125     000 0100000000 0000000000        1000 0111        43840000
-661    -1.03125   0.03125     000 0100000000 0000000000        1000 0101        c2840000
-0.281251    -1.125     0.125       001 0000000000 0000000000        0111 1101        be900000
-0.1718751    -1.375     0.375       011 0000000000 0000000000        0111 1100        be300000
+280    +1.75      0.75        110 0000000000 0000000000        1000 0011        41e00000
+270    +1.6875    0.6875      101 1000000000 0000000000        1000 0011        41d80000

3.单精度机器数 k=8,n=23,现要将机器数 0 10000111 110 0000000000 0000000000 B转成实数,机器数对应的尾数符号为_____B(1,二),该机器数对应的尾数真值(含符号)为_____D(十),实际存储的尾数数值(不含符号)为_____D(十),该机器数对应的阶码为________B(8,二),该机器数对应的阶码真值为____D(是),该机器数对应的浮点数数值为_____D(十)。

0    +1.75     0.75     1000 0111     8    448
因为 “换头没换衣服” 就直接写结果:
// 0 01111001 111 0000000000 0000000000 B
0    +1.875    0.875    0111 1001    -6    0.0292969
// 1 10000100 111 0000000000 0000000000 B
1    -1.875    0.875    1000 0100     5    -60
// 1 01111011 111 0000000000 0000000000 B
1    -1.875    0.875    0111 1011    -4    -0.1171875
// 0 10000110 111 0000000000 0000000000 B
0    +1.875    0.875    1000 0110     7    240
// 1 01111111 101 1000000000 0000000000 B
1    -1.6875   0.6875   0111 1111     0    -1.6875

4.现要将 -0.375 表示成单精度机器数即 k=8,n=23,则该机器数对应的尾数符号为_____B(1,二),该机器数对应的尾数真值(含符号)为_____D(十),实际存储的尾数数值(不含符号)为_____D(十),用原码表示的尾数数值为_______________________________B(23,二),该机器数用移码表示的阶码为________B(8,二),该机器数对应的十六进制数值为__________H。

1    -1.5    0.5    100 0000000000 0000000000    0111 1101    BEC0 0000

5.单精度机器数 k=8,n=23,现要将机器数 0 10000010 101 0000000000 0000000000 B转成实数,机器数对应的尾数符号为_____B(1,二),该机器数对应的尾数真值(含符号)为_____D(十),实际存储的尾数数值(不含符号)为_____D(十),该机器数对应的阶码为________B(8,二),该机器数对应的阶码真值为____D(十),该机器数对应的浮点数数值为_____D(十)。

0    1.625    0.625    1000 0010    3    13

草稿留底,以便回忆。

十一、CPU与存储器连接CPU

1.假设 EAX = 12345678H,EBX = 11223344H,[11223344H] = 87654321H,MOV EAX,[EBX],AL = ____H,AH = ____H,AX = ____H,EAX = __________H,EBX = __________H。

//答案在此
21		43		4321		87654321		11223344
//类似题型(答案就不写了):
8765432111223344[11223344]=12345678,eax,[ebx]1122334487654321[87654321]=44332211,eax,[ebx]1122334487654321[11223344]=13245768,ebx,[eax]

2.如图(一般题目都会给,翻开我的课本P66可见),mov dword ptr ds:[00445568H],16385a7bH 时,D31 ~ D0 引脚值为_______H(8位 十六进制),A31 ~ A2 引脚为________________________________________B(30,二),BE3 ~ BE0(编辑限制,别介)引脚值______B(4,二),W / R 引脚值为____B(1,二),M / IO 引脚值为____B(1,二),D / C 引脚值为____B(1,二)。

//答案在此
16385a7b		0000 0000 0100 0100 0101 0101 0110 10		0000		1		1		1
类似题型:
//mov eax,dword ptr ds:[00503074 H],eax = 7364A3B4 H,......
7364A3B4		0000 0000 0101 0000 0011 0000 0111 01		0000		1		1		112/10分?)
//mov word ptr ds:[0040302A H],5321 H时,D31~D6引脚......
5321		0000 0000 0100 0000 0011 0000 0010 10		0011		1		1		1
//mov AX,word ptr ds:[00403028 H]后,eax = 3642C7D8 H,D15~D0为......
C7D8		0000 0000 0100 0000 0011 0000 0010 10		1100		0		1		1
//mov dword ptr ds:[00443324H],11335577H
11335577    0000 0000 0100 0100 0011 0011 0010 01       0000		1		1		1
//mov dword ptr ds:[00403028H],10204080H       
10204080    0000 0000 0100 0000 0011 0000 0010 10       0000		1		1		1
//mov word ptr ds:[00403026H],1234H
1234        0000 0000 0100 0000 0011 0000 0010 01       0011		1		1		1
//mov word ptr ds:[0040302CH],3547H
3547        0000 0000 0100 0000 0011 0000 0010 11       1100		1		1		1
//mov AX,word ptr ds:[0040302C H],...EAX=31425768 H,...
5768        0000 0000 0100 0000 0011 0000 0010 11       1100		0		1		1
//mov EAX,dword ptr ds:[00403024 H],...EAX=33445364 H,...
33445364    0000 0000 0100 0000 0011 0000 0010 01       0000		0		1		1

3.mov dword ptr ds: [0040702D H],A1B2C3D4 H。分两次传输,第一次传输时,D31 ~ D0 为__________H(8,十六;不确定的位用 “X” 表示),A31 ~ A2引脚值为________________________________________B(30,二),BE3 ~ BE0 引脚值______B(4,二);第二次传输时,D31 ~ D0 为__________H(8,十六;不确定的位用 “X” 表示),A31 ~ A2引脚值为________________________________________B(30,二),BE3 ~ BE0 引脚值______B(4,二)。

//答案在此
B2C3D4XX		0000 0000 0100 0000 0111 0000 0010 11		0001		XXXXXXA1		0000 0000 0100 0000 0111 0000 0011 00		1110
类似题目
//mov dword ptr ds:[00407026 H],C1D2A3B4 H时,......
A3B4XXXX		0000 0000 0100 0000 0111 0000 0010 01		0011		XXXXC1D2		0000 0000 0100 0000 0111 0000 0010 10		1100
//mov dword ptr ds:[00403026 H],11223344 H时,......
3344XXXX        0000 0000 0100 0000 0011 0000 0010 01		0011		XXXX1122		0000 0000 0100 0000 0011 0000 0010 10		1100
//mov dword ptr ds:[00403027 H],11223344 H时,......
44XXXXXX        0000 0000 0100 0000 0011 0000 0010 01		0111		XX112233		0000 0000 0100 0000 0011 0000 0010 10		1000
//mov dword ptr ds:[00403025 H],11223344 H时,......
223344XX        0000 0000 0100 0000 0011 0000 0010 01		0001		XXXXXX11		0000 0000 0100 0000 0011 0000 0010 10		1110

十二、CPU设计与IO系统CPU

1.根据控制器设计方法不同,可分为三类,其中采用 门电路 实现的是( B )

A.存储逻辑型控制器 Storage Logic Controller                                //采用微指令实现,把微操作信号代码化;便于调试、维修及更改、扩充指令;
B.组合逻辑型...... Combination Logic Controller                            //
C.前两者结合型.... Combination Logic and Storage Logic Combined Controller //速度最快但难以实现;设计自动化;
D.集成电路型...... Integrated Circuit Controller                           //

2.已知某些汇编指令与机器码的清单如下:

第一行 数据为例分析:

根据以上信息,寄存器EDX 的地址编码是______B(3位,二进制),指令 “MOV EBX,EAX” 机器码依次是______H(2,十六)和______H(2,十六),机器码 8B H 和 E3 H 对应的汇编指令是____________。

//答案在此
010		8B		D8		mov esp,ebx
 “换汤不换药”
//寄存器ESP... MOV ESI,ESP... 8BH 和ECH
100		8B		F4		mov ebp,esp

3.一个指令周期由若干个____________组成。
4.32位CPU中存储正在执行指令的的下一条指令的地址是____________。
5.通过CPU查看外设是否有数据然后再进行数据传输的工作方式是________________________。
6.通过CPU发出数据传输要求,然后由专门部件实现,不需要CPU完成数据传输完的善后的工作方式是____________方式。
7.一个机器周期一般由1个____________组成,4个____________组成。
8.当外设需要进行输入输出数据,通过产生请求信号向CPU反馈以便决定是否进行传输,这种工作方式是____________方式。
9.比较指令 “cmp x, 60” 执行后,是否相等的状态值存储于____________寄存器中。
10.16位CPU中存储正在执行指令的下一条指令的地址是_______。
11.8位CPU中存储正在执行指令的下一条指令的地址是_______。
12.存储正在读取指令/数据的地址的是_______。
13.存储正在译码的指令的寄存器是_______。
14.存储指令执行结果状态的寄存器是_______。
15.通过CPU发出数据传输来源和目的地址及数量,然后由专门部件实现,数据传输完后CPU再善后的工作方式是_______方式。

//答案
3.机器周期 machine cycle
4.EIP
5.程序查询 Program quary
6.I/O通道 I/O channel
7.CPU周期 CPU cycle;时钟周期 Clock cycle
8.中断 Interruption
9.PSW
10.IP
11.PC
12.MDR
13.IR
14.PSW
15.DMA

16.若某指令系统使用 两字节 作为指令的机器码,其中 0~2 位作为源操作数的地址, 3~5 位作为目的操作数的地址,则该指令系统至多有_______条不同的指令。

//答案
1024
解析:“两字节” = 16位,“0~2” 和 “3~5” 共占了6位,剩余10位,即2^10=1024
 “换汤不换药”
//2字节;0~2;即2^13
8192
//2字节;0~3;即2^12
4096
//2字节;0~3,4~7;即2^8
256
//1字节;0~2;即2^5
32
//1字节;0~3;即2^4
16
//1字节;0~4;即2^3
8
//1字节;0~5;即2^2
4

17.某存储芯片标示 4K * 4 ,则表示该芯片有____________。

//答案
12根地址,4根数据
 “换汤不换药”
//2k*8
118//1k*8
108//4k*8
12   8
//8k*8
13   8
//16k*8
14   8
//16k*4
14   4

十三、校验码 Check Code

1.假如海明校验法中 4位校验码 P1P2P4P8 和 7位有效信息位 A6A5A4A3A2A1A0 位置关系为 P1P2A6P4A5A4A3P8A2A1A0。若字母 ‘M’ 的ASCII是 100 1101B,则它的 4位海明校验码位(偶校验)是________B(4,二),海明校验码(偶校验)是______________B(11,二)

//答案
0110	0111 0010 101
“换汤不换药”
//...若字母 ‘M’ 的ASCII是 101 1001B...
1001	1010 0111 001
//...若接收到的海明校验码(偶校验)是1011 0011 100 B,则该校验码第_____位有错(填0~11,没错填0),有效字符编码是____________B(7,二)
0		1001 100

2.设生成多项式为G(x) = x^3 + x^1 + 1,生成的多项式对应的二进制为_________B,4位有效二进制信息 1001 B对应的 7位 CRC为

//答案
1011	100 1110 
“换汤不换药”
//...G(x) = x^3 + x^2 + 1... 0011 B对应的... 
1101	001 1010
//...则若接收到的7位CRC码为100 1100,用G(x)做 模2除,得到的三位余数为______B,说明传输数据_______(填 “有错”[指余数≠0] 或 “没错”)
010		有错
//...G(x) = x^3 + x^2 + 1,则若接收到的7位CRC码为100 0001,用G(x)做 模2除,...
111		有错

3.假如海明校验法中 4位校验码 P1P2P4P8 和 7位有效信息位 A6A5A4A3A2A1A0 位置关系为 P1P2A6P4A5A4A3P8A2A1A0。若 接收到的海明校验码位(偶校验)是 0111 0010 001 B,则该校验码第________位有错(回答0~11,没错答0),有效字符编码是____________B(7,二)

//答案
9		1001 101
  1. 字符 “A” 的7位二进制数为100 0001B,若数据传输时用 奇校验 ,则对应编码为________________B,若用 偶校验 ,则为________________B。
//答案
1100 0001		0100 0001
“换汤不换药”
//"J" 的7位二进制数为100 1010B...
0100 1010		1100 1010


上述乃平时习题

十四、考试测试题

循环结构

在这里插入代码片

递归

1.编写一个求排序组合数的函数 int Com(int N, int M),该函数表示从N个元素中任意选择M个元素的组合数,可用如下公式表示(式中C上m下n表示 Com(N, M)):

运行后输入:6 2,则结果输出:15

com porc x:dword,y:dword
local t:dword
mov ebx,y
.if ebx==1
	mov eax,x
.else if ebx==x
	mov eax,1
.else
	mov ebx,x
	dec ebx
	mov ecx,y
	dec ecx
	invoke Com,ebx,ecx;b[-1]
	mov t,eax
	mov ebx,x
	dec ebx
	mov ecx,y
	invoke Com,ebx,ecx
	add t,eax
	mov eax,t
.endif
ret
Com endp

十五、OD吾爱破解软件

PW文件:/download/weixin_45308154/85776674 含部分答案

//查找方法
1. F8键按到底,确认地址;
2. 进入地址;
3. F8键按到底,输入密码;
4. 从最近的一个 call 进入;
5. 进入 pop 前面的call;
6. 再次进入 pop 前面的call;
7. 答案就在第二个call。

更新仍在继续…

⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱嘿嘿都看到这儿了~
⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱↓点赞 ↓收藏 ↓打赏 三连 (#^ ^#) ❤不过分吧

《计算机组成原理与汇编语言》Win32考试系统

仅供学习参考,自己做出来的才是王道。

目录快查

    • 一、数据类型DataType
    • 二、MASM整数+-*/% IntegerOperation
    • 三、MASM实数+-*/ RealOperation
    • 四、MASM函数Function
    • 五、选择结构SelectionStructure
    • 六、循环结构 LoopStructure
    • 七、C嵌入式汇编 EmbeddedAssembly
    • 八、子程序(函数)
    • 九、递归程序设计 Recursive Programming
    • 十、浮点数表示
    • 十一、CPU与存储器连接CPU
    • 十二、CPU设计与IO系统CPU
    • 十三、校验码 Check Code
    • 十四、考试测试题
      • 循环结构
      • 递归
    • 十五、OD吾爱破解软件

如有错误,请凭正确 截图私聊证实。结课后个人系统数据被清空,无法重新查改验证,请见谅~

一、数据类型DataType

1.键盘输入一个字母,然后输出该字母。
Use the keyboard to input a letter, and then output the letter.
运行后若输入Run the program and input:A B
则结果输出Output the result:'A’ “B”
运行后若输入Run the program and input:a b
则结果输出Output the result:'a’ “b”

.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be included
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
 ;**/
fmt byte '%c %c' ,0
a byte ?
b byte ?
fmt1 byte '"%c"',0
fmt2 byte "'%c' ",0
.code
start:
invoke scanf, addr fmt,addr a,addr b
invoke printf, addr fmt2,dword ptr a
invoke printf, addr fmt1,dword ptr b
 ;**/
invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

2.键盘输入2个整数,然后按相反顺序输出这2个整数。
Use the keyboard to input 2 integers, and then output these 2 integers in reverse order.
运行后若输入Run the program and input:3 4
则结果输出Output the result:4 3
运行后若输入Run the program and input:1 2
则结果输出Output the result:2 1

.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be included
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
 ;**/
fmt byte '%d %d',0
a dword ?
b dword ?
.code
start:
invoke scanf, addr fmt, addr a, addr b
invoke printf, addr fmt, b,a

 ;**/
invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

3.键盘输入2个实数,然后按相反顺序输出这2个实数。
Input 2 real numbers from the keyboard, and then output these 2 real numbers in reverse order.
运行后若输入Run the program and input:3.3 4.45
则结果输出Output the result:4.45 3.3
运行后若输入Run the program and input:1.35 2.4
则结果输出Output the result:2.4 1.35

.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be included
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
 ;**/
fmt byte '%lf %lf',0
a qword ?
b qword ?
fmt1 byte '%g %g',0
.code
start:
invoke scanf, addr fmt, addr a, addr b
invoke printf, addr fmt1, b,a

 ;**/
invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

4.定义结构体商品,含编号、品名、单价、数量,输入一个商品信息求其金额并输出(按“%g”格式输出)。
Define a product structure, including serial number, product name, unit price, and quantity. Enter a product information to find the amount and output (output in “%g” format).
若运行后输入Run the program and input:S001 小刀 4.5 2
则运行结果输出Output the result:编号:S001,品名:小刀,单价:4.5,数量:2,金额:9

.386
.model flat, stdcall
option casemap :none
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib		;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
 ;**/
.data
fmt DB '%s %s %lf %d',0
fmt1 DB '编号:%s,品名:%s,单价:%g,数量:%d,金额:%g',0

Goods struct
no byte 14 DUP(?)
gname byte 20 DUP(?)
cost qword ?
num dword ?
total qword ?
Goods ends
s Goods <>

.code
start:
invoke scanf,addr fmt,addr s.no,addr s.gname ,addr s.cost,addr s.num
FLD s.cost
Fimul s.num
FSTP s.total
invoke printf,addr fmt1, addr s.no,addr s.gname ,s.cost,s.num,s.total

invoke ExitProcess,0
end start
 ;**/

二、MASM整数±*/% IntegerOperation

1.键盘输入整数x、y、z的值,求如下表达式的值:
Enter the values of integers x, y, and z from the keyboard, and obtain the value of the following expression:
x*y+x%y-z
运行后若输入Run the program and input:8 4 2
则结果输出Output the result:8*4+8%4-2=30

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
fmt DB '%d %d %d',0
x dword ?
y dword ?
z dword ?
a dword ?
b dword ?
d dword ?
e dword ?
fmt1 DB '%d*%d+%d%%%d-%d=%d',0
.code
start:
invoke scanf, addr fmt, addr x, addr y, addr z

MOV EAX,x
IMUL y
MOV a,EAX

MOV EAX,x
CDQ
IDIV y
MOV b,EDX

MOV EAX,a
ADD EAX,b
MOV d,EAX

MOV EAX,d
SUB EAX,z
MOV e,EAX
invoke printf, addr fmt1,x,y,x,y,z,e 

invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

 ;**/

2.键盘输入整数x、y、z的值,求如下表达式的值:
Enter the values of integers x, y, and z from the keyboard, and obtain the value of the following expression:
x*y+x/y-z
运行后若输入Run the program and input:8 4 2
则结果输出Output the result:8*4+8/4-2=32

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
fmt DB '%d %d %d',0
x dword ?
y dword ?
z dword ?
a dword ?
b dword ?
d dword ?
e dword ?
fmt1 DB '%d*%d+%d/%d-%d=%d',0
.code
start:
invoke scanf, addr fmt, addr x, addr y, addr z

MOV EAX,x
IMUL y
MOV a,EAX

MOV EAX,x
CDQ
IDIV y
MOV b,EAX

MOV EAX,a
ADD EAX,b
MOV d,EAX

MOV EAX,d
SUB EAX,z
MOV e,EAX
invoke printf, addr fmt1,x,y,x,y,z,e 

invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

 ;**/

3.输入两个小写字母,然后输出其相应的大写字母。
Enter two lowercase letters, and then output their corresponding uppercase letters.
运行后输入Run the program and input:
a b
则结果输出Output the result:
A B

.386				;选择的处理器
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明
.data				;⑤数据段
 ;**/
fmt byte '%c %c',0
a byte ?
b byte ?
.code
start:
invoke scanf, addr fmt, addr a, addr b
sub a,32
sub b,32
invoke printf, addr fmt, dword ptr a, dword ptr b
 ;**/
invoke	ExitProcess,0		;退出进程,返回值为0
end start
/***asm***/

三、MASM实数±*/ RealOperation

1.键盘输入实数x、y、z的值,求如下表达式的值(数值结果用%g格式输出):
Enter the values of real numbers x, y, and z from the keyboard, and obtain the value of the following expression (the numerical result is output in %g format):
x*y+x/y-z
运行后若输入Run the program and input:7.0 4.0 2.0
则结果输出Output the result:7×4+7/4-2=27.75
(编辑格式限制:实际“×”要用星号)

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype
.data				;⑤数据段 data segment
fmt byte '%lf %lf %lf',0
x qword ?
y qword ?
z qword ?
a qword ?
b qword ?
d qword ?
e qword ?
fmt1 byte '%g*%g+%g/%g-%g=%g',0
.code
start:
invoke scanf, addr fmt, addr x, addr y,addr z

FLD x
FMUL y
FSTP a

FLD x
FDIV y
FSTP b

FLD a
FADD b
FSTP d

FLD d
FSUB z
FSTP e

invoke printf, addr fmt1,x,y,x,y,z,e
invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

 ;**/

四、MASM函数Function

1.键盘输入实数x的值,求如下表达式的值(保留2位小数):
Enter the value of the real number x from the keyboard, and obtain the value of the following expression (retaining 2 decimal places):

运行后若输入Run the program and input:0.5
则结果输出Output the result:0.65

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype

.data				;⑤数据段 data segment
fmt byte '%lf',0
x qword ?
y qword ?
z qword ?
a qword 2.0
b qword ?
d qword ?
e qword ?
f qword ?
fmt1 byte '%.2lf',0

.code
start:
invoke scanf, addr fmt, addr x

FLD x
FMUL x
FSTP y

FLD x
Fsin
FSTP z

FLD x
Fcos
FSTP b

FLD a
FADD b
FSTP d

FLD z
FDIV d
FADD y
FSTP e

FLD e
Fsqrt 
FSTP f

invoke printf, addr fmt1,f

invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start

 ;**/

2.已知机器人当前的位置为(0,0),若该机器人的下一个位置为(x,y),请计算该机器人前进的方向角(角度)。输入x和y值,用反正切函数指令(FPATAN)求角度。
It is known that the current position of the robot is (0,0). If the next position of the robot is (x,y), please calculate the direction angle (angle) of the robot. Enter the x and y values, and use the arctangent function command (FPATAN) to obtain the angle.
运行后若输入Run the program and input:1.0 1.0
则结果输出Output the result:45
运行后若输入Run the program and input:-1.0 1.0
则结果输出Output the result:135
运行后若输入Run the program and input:1.0 -1.0
则结果输出Output the result:-45
运行后若输入Run the program and input:-1.0 -1.0
则结果输出Output the result:-135

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype

.data				;⑤数据段 data segment
fmt byte '%lf %lf',0
x qword ?
y qword ?
z qword ?
a qword 180.0
b qword 3.1415926
d qword ?
fmt1 byte '%g',0

.code
start:
invoke scanf, addr fmt, addr x,addr y

FLD y
FLD x
Fpatan
FSTP z

FLD z
FMUL a
FDIV b
FSTP d

invoke printf, addr fmt1,d

invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start
 ;**/

3.键盘输入实数y和实数x的值,求q=ylg(x)的值(用%g格式显示):
Input the value of real number y and real number x with the keyboard, and find the value of q=ylg(x) (displayed in %g format):
运行后若输入Run the program and input:0.5 10
则结果输出Output the result:0.5
运行后若输入Run the program and input:1.5 0.1
则结果输出Output the result:-1.5

 ;**/
.386				;选择的处理器Choose the processor
.model flat, stdcall	
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件Specify the header file to be inc luded
includelib	kernel32.lib	;要引用的库文件Specify the library file to be included
includelib	msvcrt.lib	;引用C库文件Specify the C library file to be included
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明 Declare the C scanf function prototype
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明 Declare the C printf function prototype

.data				;⑤数据段 data segment
fmt byte '%lf %lf',0
x qword ?
y qword ?
a qword ?
b qword 10.0
d qword ?
q qword ?
fmt1 byte '%g',0

.code
start:
invoke scanf, addr fmt, addr y,addr x

fld y
fld x
fyl2x
Fdiv y
fstp a

fld y
fld b
fyl2x
Fdiv y
fstp d

FLD a
Fdiv d
Fmul y
Fstp q

invoke printf, addr fmt1,q

invoke	ExitProcess,0		;退出进程,返回值为0 Exit process, return 0
end start
 ;**/

4.键盘输入实数q,求实数q的整数部分n和小数部分p并输出(用%g格式输出):
Input the real number q from the keyboard, obtain the integer part n and the decimal part p of the real number q and output (output in %g format):
运行后若输入Run the program and input:4.0
则结果输出Output the result:4 0
运行后若输入Run the program and input:4.1
则结果输出Output the result:4 0.1
运行后若输入Run the program and input:4.9
则结果输出Output the result:4 0.9
运行后若输入Run the program and input:-4.0
则结果输出Output the result:-4 -0
运行后若输入Run the program and input:-4.1
则结果输出Output the result:-4 -0.1
运行后若输入Run the program and input:-4.9
则结果输出Output the result:-4 -0.9

 ;**/
.386			
.model flat, stdcall	
option casemap:none		
include	kernel32.inc
includelib	kernel32.lib
includelib	msvcrt.lib	
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg

.data			
fmt byte '%lf',0
q qword ?
n qword ?
p qword ?
a qword 1.0
fmt1 byte '%g %g',0

.code
start:
invoke scanf, addr fmt, addr q

FLD a
FLD q
Fprem
FSTP p
FSTP a

FLD q
Fsub p
FSTP n

invoke printf, addr fmt1,n,p

invoke	ExitProcess,0	
end start
 ;**/

5.键盘输入实数p(p介于-1~1之间)的值,求v=2^p的值(保留3位小数):
Use the keyboard to input the value of the real number p (p is between -1 and 1), and obtain the value of v=2p (retain 3 decimal places):
运行后若输入Run the program and input:0.5
则结果输出Output the result:1.414
运行后若输入Run the program and input:1
则结果输出Output the result:2.000
运行后若输入Run the program and input:-1
则结果输出Output the result:0.500

 ;**/
.386			
.model flat, stdcall	
option casemap:none		
include	kernel32.inc
includelib	kernel32.lib
includelib	msvcrt.lib	
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg

.data			
fmt byte '%lf',0
v qword ?
p qword ?
q qword ?
a qword 1.0
fmt1 byte '%.3lf',0

.code
start:
invoke scanf, addr fmt, addr p

FLD p
F2xm1
Fadd a
FSTP v

invoke printf, addr fmt1,v

invoke	ExitProcess,0	
end start
 ;**/

6.键盘输入实数v和整数n的值,求w=v×(2^n)的值:
Enter the value of the real number v and the integer n with the keyboard, and obtain the value of w=v*2n:
运行后若输入Run the program and input:1.5 3
则结果输出Output the result:1.5×2^3=12

 ;**/
.386			
.model flat, stdcall	
option casemap:none		
include	kernel32.inc
includelib	kernel32.lib
includelib	msvcrt.lib	
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg

.data			
fmt byte '%lf %lf',0
v qword ?
n qword ?
w qword ?
fmt1 byte '%g*2^%g=%g',0

.code
start:
invoke scanf, addr fmt, addr v,addr n

FLD n
FLD v
Fscale
Fstp w
Fstp n

invoke printf, addr fmt1,v,n,w

invoke	ExitProcess,0	
end start
 ;**/

7.键盘输入实数x和实数y的值,求w=x^y的值(保留2位小数)。
Input the value of real number x and real number y with the keyboard, and find the value of w=xy (retaining 2 decimal places).
提示 Hint:

先求指数 q=y*(以2为底x的对数),再求出q的整数n和小数p,然后求v=2的p次方,最后求w=v*(2^n)。
First find the exponent , then get the values of n and decimal p of q, then find v=2p, and finally get w=v*(2^n).
运行后若输入Run the program and input:0.5 2
则结果输出Output the result:0.25
运行后若输入Run the program and input:4 2
则结果输出Output the result:16.00

 ;**/
.386			
.model flat, stdcall	
option casemap:none		
include	kernel32.inc
includelib	kernel32.lib
includelib	msvcrt.lib	
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg

.data			
fmt byte '%lf %lf',0
x qword ?
y qword ?
z qword 1.0
q qword ?
p qword ?
n qword ?
v qword ?
w qword ?
fmt1 byte '%.2lf',0

.code
start:
invoke scanf, addr fmt, addr x,addr y

FLD y  ;求q
FLD x
FYL2X
FSTP q

FLD z  ;取余得小数p
FLD q
FPREM
FSTP p
FSTP z

FLD q  ;整数n
FLD z
FSCALE
FSTP n
FSTP q

FLD p  ;求v
F2XM1
FADD z
FSTP v

FLD v  ;结果w
FMUL n
FSTP w
invoke printf, addr fmt1,w

invoke	ExitProcess,0	
end start
 ;**/

五、选择结构SelectionStructure

1.输入一个整数,用.IF语句判断能否被3,5,7整除。具体情况如下:
1.若同时能被3,5,7整除输出357;
2.若同时能被3,5整除输出35;
3.若同时能被3,7整除输出37;
4.若同时能被5,7整除输出57;
5.若只能被3整除输出3;
6.若只能被5整除输出5;
7.若只能被7整除输出7;
8.若都不整除,则不输出信息。
Enter an integer and use the .IF statement to determine whether it can be divisible by 3, 5, and 7. Details are as follows:

  1. If it can be divisible by 3, 5, and 7 at the same time, output 357;
  2. If it can be divisible by 3 and 5 at the same time, output 35;
  3. If it can be divisible by 3 and 7 at the same time, output 37;
  4. If it can be divisible by 5 and 7 at the same time, output 57;
  5. If it can only be divisible by 3, output 3;
  6. If it can only be divisible by 5, output 5;
  7. If it can only be divisible by 7 and output 7;
  8. If it is not divisible, no information will be output.
    运行后输入Run the program and input:
    105
    则结果输出Output the result:
    357
    运行后输入:
    15
    则结果输出Output the result:
    35
    运行后输入:
    14
    则结果输出Output the result:
    7
    运行后输入:
    121
    则结果输出Output the result:
    (没有输出)
.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段
 ;**/
fmt byte '%d',0
x dword ?
a dword ?
b dword ?
d dword ?
l dword 3
m dword 5
n dword 7
fmt1 byte '3',0
fmt2 byte '5',0
fmt3 byte '7',0

.code
start:
invoke scanf, addr fmt, addr x
mov eax,x
cdq
idiv l
mov a,edx

mov eax,x
cdq
idiv m
mov b,edx

mov eax,x
cdq
idiv n
mov d,edx

.if a==0
   invoke printf, addr fmt1
.endif
.if b==0
   invoke printf, addr fmt2
.endif
.if d==0
   invoke printf, addr fmt3
.endif


 ;**/
invoke ExitProcess,0		;⑨退出进程,返回值为0
end	start					;⑩指明程序入口点start

2.用.IF….ELSEIF伪指令实现输入一个分数(0~100的整数),输出相应的成绩等级。
分数与成绩等级对应关系分别为90-100分为优秀,80-89为良好,70-79为中,60-69为及格,0-59为不及格。
Use the .IF…ELSEIF pseudo-instruction to input a score (an integer from 0 to 100) and output the corresponding grade. The corresponding relationship between scores and grades is 90 to 100 for excellent(优秀), 80 to 89 for good(良好), 70 to 79 for medium(中), 60 to 69 for passing(及格), and 0 to 59 for failing(不及格).
运行后若输入Run the program and input:95
则结果输出Output the result:优秀
运行后若输入Run the program and input:86
则结果输出Output the result:良好
运行后若输入Run the program and input:73
则结果输出Output the result:
运行后若输入Run the program and input:66
则结果输出Output the result:及格
运行后若输入Run the program and input:53
则结果输出Output the result:不及格

.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段
 ;**/
fmt byte '%d',0
x sdword ?
fmt1 byte '优秀',0
fmt2 byte '良好',0
fmt3 byte '中',0
fmt4 byte '及格',0
fmt5 byte '不及格',0

.code
start:
invoke scanf, addr fmt, addr x

.if x>=90 && x<=100
   invoke printf, addr fmt1

.elseif x>=80 && x<=89
   invoke printf, addr fmt2
.elseif x>=70 && x<=79
   invoke printf, addr fmt3
.elseif x>=60 && x<=69
   invoke printf, addr fmt4
.else
   invoke printf, addr fmt5
.endif
 ;**/
invoke ExitProcess,0		;⑨退出进程,返回值为0
end	start					;⑩指明程序入口点start

3.编写一段程序,用.IF语句(不用jcc指令)完成下面计算公式,其中:变量x和y都是整数类型。

运行后若输入Run the program and input:-4
则结果输出Output the result:-4
运行后若输入Run the program and input:4
则结果输出Output the result:16
运行后若输入Run the program and input:22
则结果输出Output the result:66

 ;**/
.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段

fmt byte '%d',0
x sdword ?
y sdword ?
a dword 3

.code
start:
invoke scanf, addr fmt, addr x

.if x<=0
   invoke printf, addr fmt,x
.endif

.if x>0 && x<10
mov eax,x
Imul eax,x
mov y,eax
invoke printf, addr fmt,y
.endif

.if x>=10
mov eax,x
Imul eax,a
mov y,eax
invoke printf, addr fmt,y
.endif

invoke ExitProcess,0		;⑨退出进程,返回值为0
end	start					;⑩指明程序入口点start


 ;**/

4.编写一段程序,用jcc指令(不用.IF语句)完成下面计算公式,其中:变量x和y都是整数类型。

运行后若输入Run the program and input:-4
则结果输出Output the result:-4
运行后若输入Run the program and input:4
则结果输出Output the result:16
运行后若输入Run the program and input:22
则结果输出Output the result:66

 ;**/
.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段

fmt byte '%d',0
x sdword ?
y sdword ?
a dword 3

.code
start:
invoke scanf, addr fmt, addr x
cmp x,0
JLE LE0

cmp x,10
JL L10
  mov eax,x
  Imul a
  mov y,eax
jmp done

L10:
mov eax,x
Imul x
mov y,eax
jmp done

LE0:
mov eax,x
mov y,eax
done:
invoke printf, addr fmt , y
invoke ExitProcess,0		;⑨退出进程,返回值为0
end	start					;⑩指明程序入口点start
 ;**/

5.编写程序,完成下面计算公式,其中:变量x和y都是REAL8类型,结果保留2位小数。

;**/
.386			
.model flat, stdcall	
option casemap:none		
include	kernel32.inc
includelib	kernel32.lib
includelib	msvcrt.lib	
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg

.data
fmt byte '%lf',0
x qword ?
y qword ?
a qword 2.0
b qword -1.9
d qword 1.5
fmt1 byte '%.2lf',0

.code
start:
invoke scanf, addr fmt, addr x
FEQU=40H
FLESS=1
FLD x
FCOMP b
fnstsw ax

.IF ah&FLESS          ;<-1.9
FLD x ;sinx
Fsin
FSTP y

.ELSE                      ;>=-1.9
   FLD x
   FCOMP d
   fnstsw ax
   .IF ah&(FLESS or FEQU) ;<=1.5
      FLD x ;2x
      Fmul a
      FSTP y

    .ELSE ;>1.5
         FLD x ;cosx
         Fcos
         FSTP y
   .ENDIF
.ENDIF
invoke printf, addr fmt1,y
invoke	ExitProcess,0	
end start

 ;**/

六、循环结构 LoopStructure

1.输入若干整数,统计正数与负数和。
运行后若输入Run the program and input:1 -2 3 -4
则结果输出Output the result:正数和为:4 负数和为:-6

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
szFmt  	BYTE	'正数和为:%d 负数和为:%d',0
 ;**/
fmt byte '%d',0
n sdword ?
s sdword 0
s1 sdword 0

.code
start:
invoke scanf, addr fmt,addr n
.while eax==1
  .if n>=0
    mov ebx,s
    add ebx,n
    mov s,ebx
  .else
    mov ebx,s1
    add ebx,n
    mov s1,ebx
  .endif
invoke scanf, addr fmt,addr n
.endw
invoke printf, addr szFmt, s,s1
ret
 ;**/

2.编写求1+2+3+…+n和的程序(整数n由键盘输入且n>1)。
运行后若输入Run the program and input:10
则结果输出Output the result:1+…+10=55
运行后若输入Run the program and input:100
则结果输出Output the result:1+…+100=5050

 ;**/
.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明

.data				;⑤数据段
fmt DB '%d',0
n dword ?
fmt1 DB '1+...+%d=%d',0

.code
start:
invoke scanf, addr fmt,addr n
mov ecx,1;累加和,初始化为0
mov eax,0;循环次数寄存器赋值
.while ecx<=n;循环控制           
   add eax,ecx
      inc ecx                
.endw
invoke printf, addr fmt1, n, eax

ret;invoke ExitProcess,0
end start 

 ;**/

3.键盘输入若干对整数x、y,求其相应的最大公约数。
运行后若输入Run the program and input:
18 12
8 12
10 12

则结果输出Output the result:
6
4
2

 ;**/
.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段

fmt byte '%d %d',0
x dword ?
y dword ?
a dword ?
b dword ?
d dword ?
fmt1 byte '%d',13,10,0

.code
start:
invoke scanf, addr fmt,addr x,addr y

.while eax==2
  mov eax,x
  .if eax<y ;除数与被除数交换
    mov eax,x
    xchg eax,y
    mov  x,eax
  .endif

  mov eax,x
  cdq
  div y;余数在edx,商在eax

  .if edx==0;余数为0,该除数即为最大公约数
    mov eax,y
    mov a,eax
  .endif

  mov eax,y
  .while edx!=0
    mov a,edx
    cdq
    div a
    mov eax,a
  .endw
invoke printf, addr fmt1, a
invoke scanf, addr fmt,addr x,addr y
.endw

ret
end start 

 ;**/

4.键盘输入若干对实数x、y,求各对实数乘积和。
运行后若输入Run the program and input:
2.5 2
1.5 4
2.2 2

则结果输出Output the result:
15.4

 ;**/
.386
.model flat, stdcall
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib				;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
option casemap :none 

.data
fmt DB '%lf %lf',0
fmt1 DB '%g',0
x qword ?
y qword ?
s qword ?
s1 qword ?

.code
start:
Fld s1
invoke scanf, addr fmt, addr x, addr y

.while EAX==2 ;读取2个数据
Fld x
Fmul y
Fstp s
Fadd s
invoke scanf, addr fmt, addr x, addr y
.endw
Fstp s1

invoke printf, addr fmt1, s1

invoke ExitProcess,0
end start
 ;**/

5.键盘输入一串字符(最多80个字符),输出其中的数字。
运行后若输入Run the program and input:ab4du5jkf8
则结果输出Output the result:458

 ;**/
.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段

n dword ?
s db 80 Dup(0)
fmt db '%s',0
fmt1 db '%c',0

.code
start:
invoke scanf, addr fmt,addr s
mov esi,0

.while s[esi]!=0
    .if s[esi]>='0' && s[esi]<='9'
        invoke printf, addr fmt1,dword ptr s[esi]
    .endif
    inc esi
.endw
invoke printf, addr fmt1,n

ret
end start
 ;**/

6.统计对角线元素之和并输出。以下程序运行后,首先输入一个小于10的整数n,然后输入n行n列的整数矩阵,最后统计对角线元素(行列下标值相等或行列下标值之和等于n-1)之和并输出。
运行后若输入Run the program and input:
5
9 8 6 4 2
1 2 3 4 5
6 7 8 9 3
0 9 8 7 6
5 4 3 2 1

则结果输出Output the result:
47

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
fmt  	BYTE	'%d',0
Sum    DWORD 0
n      DWORD ?
Arr    DWORD 10 DUP(10 DUP (?))
.code
start:
invoke scanf,addr fmt,addr n
MOV ESI,0;行下标i初值
MOV EBX,0;存每行起始地址
.WHILE ESI<n
MOV EDI,0;列下标j初值
.WHILE EDI<n
pushA;调用函数之前所有寄存器入栈保护起来
invoke scanf,addr fmt,addr Arr[EBX+EDI*4]
popA;调用函数之后所有寄存器出栈恢复为原值
INC EDI
.ENDW
INC ESI
MOV EAX,n
SHL EAX,2;EAX=n*4,左移2位相当于*22
LEA EBX,[EBX+EAX];每循环一次EBX+=n*4
.ENDW
 ;**/
mov esi,0
mov ebx,0
.while esi<n
   mov edi,0
   .while edi<n
      MOV EAX,ESI
      ADD EAX,EDI
      ADD EAX,1
      .IF ESI==EDI||EAX==n
         MOV ECX,Sum
         ADD ECX,Arr[EBX+EDI*4]
         MOV Sum,ECX
      .ENDIF
      INC EDI
   .ENDW
   INC ESI
   MOV EAX,n
   SHL EAX,2    
   LEA EBX,[EBX+EAX]
.ENDW
 ;**/
invoke printf,addr fmt,Sum
ret
end start 

7.键盘输入若干对整数x、y,求其相应的最小公倍数。
运行后若输入Run the program and input:
18 12
8 12
10 12

则结果输出Output the result:
36
24
60

.386
.model flat, stdcall
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib				;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
option casemap :none 
 ;**/
.data				;⑤数据段

fmt byte '%d %d',0
x dword ?
y dword ?
a dword ?
b dword ?
d dword ?
fmt1 byte '%d',13,10,0

.code
start:
invoke scanf, addr fmt,addr x,addr y

.while eax==2
  mov eax,x
  .if eax<y ;除数与被除数交换
    mov eax,x
    xchg eax,y
    mov  x,eax
  .endif

  mov eax,x
  cdq
  div y;余数在edx,商在eax

  .if edx==0;余数为0,该除数即为最大公约数
    mov eax,y
    mov a,eax
  .endif

  mov eax,y
  .while edx!=0
    mov a,edx
    cdq
    div a
    mov eax,a
  .endw
    mov eax,x
    imul y
    cdq
    div a
    mov b,eax
invoke printf, addr fmt1, b
invoke scanf, addr fmt,addr x,addr y
.endw

ret
end start 
 ;**/

8.键盘输入若干实数,求其和。
运行后若输入Run the program and input:
1.2 2.3 3.4
则结果输出Output the result:
6.9

.386
.model flat, stdcall
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib				;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
option casemap :none 
 ;**/
.data
fmt DB '%lf',0
fmt1 DB '%g',0
x qword ?
s qword 0.0

.code
start:
Fld s
invoke scanf, addr fmt, addr x

.while EAX==1
Fadd x
invoke scanf, addr fmt, addr x
.endw

Fstp s
invoke printf, addr fmt1, s
invoke ExitProcess,0
end start

 ;**/

9.键盘输入若干个复数,分别求其模,最后再求所有模之和并显示(保留1位小数)。

运行后若输入Run the program and input:
3.0 4.0
1.0 1.0
6.0 8.0

则结果输出Output the result:
16.4

.386
.model flat, stdcall
option casemap :none 
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib				;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
 ;**/
.data
fmt DB '%lf %lf',0
fmt1 DB '%.1lf',0
x qword ?
y qword ?
a qword ?
s qword ?
s1 qword ?

.code
start:
Fld s1
invoke scanf, addr fmt, addr x, addr y

.while EAX==2 ;读取2个数据
Fld x
Fmul x
Fstp a

Fld y
Fmul y
Fadd a
Fsqrt
Fstp s

Fadd s

invoke scanf, addr fmt, addr x, addr y
.endw
Fstp s1

invoke printf, addr fmt1, s1

invoke ExitProcess,0
end start
 ;**/

10.键盘输入正整数n,编程求1到正整数n之间的所有奇数之和并输出。
运行后若输入Run the program and input:5
则结果输出Output the result:1到5的奇数和为9
运行后若输入Run the program and input:10
则结果输出Output the result:1到10的奇数和为25

.386
.model flat, stdcall
option casemap :none
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib		;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
 ;**/
.data				;⑤数据段
fmt DB '%d',0
n dword ?
s dword 1
fmt1 DB '1到%d的奇数和为%d',0

.code
start:
invoke scanf, addr fmt,addr n
mov ecx,1
mov eax,0
.while ecx<=n          
   add eax,ecx
   inc ecx
   inc ecx
.endw
invoke printf, addr fmt1, n, eax

ret;invoke ExitProcess,0
end start 

 ;**/

11.编程求若干字符串的长度(字符串以0作为结束标志)。
运行后若输入:
abc
则结果输出:
3
运行后若输入:
abcdef abc
则结果输出:
6
3

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
 ;**/
s db 80 Dup(0)
fmt db '%s',0
fmt1 db '%d',13,10,0

.code
start:
invoke scanf, addr fmt,addr s
.while eax==1
  mov edi,0
  .while s[edi]!=0
    inc edi
  .endw
invoke printf, addr fmt1,edi
invoke scanf,  addr fmt,addr s
.endw
ret
end start
 ;**/

12.输入一个字符和一个不含空格的字符串,统计该字符在字符串中出现的次数。
运行后输入:
s Thisisateststring
则结果输出:
'Thisisateststring’中有4个’s’字符
运行后输入:
h This
则结果输出:
'This’中有1个’h’字符

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc	;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg;C语言printf函数原型声明
.data				;数据段
 ;**/
x DB ?
s DB 80 DUP(0)
num dword 0
fmt DB '%c %s',0
fmt1 DB '''%s''中有%d个''%c''字符',0

.code
start:
invoke scanf, addr fmt, addr x, addr s
mov edi,0
mov esi,0
mov al,x
.while s[edi]!=0
   mov ah,s[edi]
   .if ah==al
      inc esi
   .endif
   inc edi
.endw
mov num,esi
invoke printf, addr fmt1,addr s, num, dword ptr x

 ;**/
invoke ExitProcess,0		
end	start		

七、C嵌入式汇编 EmbeddedAssembly

1.键盘输入整数x、y、z,然后输出x*y+z的值。
Keyboard input integers x, y, z, and then output the value of x*y+z.
运行后若输入Run the program and input:3 4 5
则结果输出Output the result:3*4+5=17

#include "stdio.h"
void main()
{
	int x,y,z,t;
	scanf("%d %d %d",&x,&y,&z);
	__asm
	{
/*【*/
mov eax,x
mul y
add eax,z
mov t,eax

/*】*/
	}
	printf("%d*%d+%d=%d",x,y,z,t);
}

2.键盘输入任一个字符,然后以此字符填充数组a[41]。
Input any character on the keyboard, and then fill the array a[41] with this character.
注意:填充40个字符即可。Note: Just fill in 40 characters.
如 For example:
运行后输入Run the program and input:A
则结果输出Output the result:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

#include "stdio.h"
void main()
{
char a[41]={0},c;
scanf("%c",&c );
	__asm
	{
/*【*/
mov al,c
lea edi,a
mov ecx,40
again:
stosb
loop again

/*】*/
	}
	printf("%s",a);
}

3.键盘输入任一个整数n和一个汉字(即两个字符),然后以此汉字填充p指定位置。
注意:最多填充40个汉字(n<=40)。

Input any integer n and a Chinese character (that is, two characters) on the keyboard, and then fill the designated position of p with this Chinese character.
Note: Fill up to 40 Chinese characters (n<=40).
如 For example:
运行后输入Run the program and input:4 字
则结果输出Output the result:字字字字

#include "stdio.h"
void main()
{
char c1,c2,p[81]={0};
int n;
scanf("%d %c%c",&n,&c1,&c2);
	__asm
	{
/*【*/

cld
lea edi,p
mov al,c1
mov ah,c2
mov ecx,n
rep stosw

/*】*/
	}
	printf("%s",p);
}

4.键盘输入一串字符给数组a,然后请你将其复制到数组b。
The keyboard enters a string of characters into array a, and then asks you to copy it to array b.
如 For example:
运行后输入Run the program and input:ABCDEFG
则结果输出Output the result:ABCDEFG

#include "stdio.h"
void main()
{
char a[80],b[80];
scanf("%s",a);
	__asm
	{
/*【*/
lea esi,a
lea edi,b
mov ecx,80
rep movsb

/*】*/
	}
	printf("%s",b);
}

5.将字符数组a[63]中的数字删除(相当于把字母移到起始位置)。
注意:字符串结束标志也移。

Delete the number in the character array a[63] (equivalent to moving the letter to the starting position).
Note: The end of the string is also moved.
如 For example:
运行后输入Run the program and input:null(不输入)
则结果输出Output the result:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

#include "stdio.h"
void main()
{
char a[63]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	__asm
	{
/*【*/
cld
lea esi,a+10
lea edi,a
mov ecx,53
rep movsb
/*】*/
	}
	printf("%s",a);
}

6.将字符数组a[63]中的字母向后移10个位置。
注意:前10个位置字母不变。

Move the letters in the character array a[63] back 10 positions.
Note: The first 10 position letters remain unchanged.
如 For example:
运行后输入Run the program and input:null(不输入)
则结果输出Output the result:ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

#include "stdio.h"
void main()
{
char a[63]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",c;
	__asm
	{
/*【*/
std
lea esi,a+51
lea edi,a+61
mov ecx,52
rep movsb
cld
/*】*/
	}
	printf("%s",a);
}

7.输入两字符串,编程判断两字符串是否相等。
Input two character-strings and program to judge whether the two character-strings are equal.
运行后输入Run the program and input:abcd abcdef
则结果输出Output the result:不相等
运行后输入Run the program and input:abcdef abcd
则结果输出Output the result:不相等
运行后输入Run the program and input:abcd abcd
则结果输出Output the result:相等

#include "stdio.h"
void main()
{
char S[80],D[80];
int flag=1;//预设flag标记,默认相等
scanf("%s %s",S,D);
	__asm
	{
/*【*/
cld
mov al,0
lea edi,S
mov ecx,80
repne scasb
lea eax,S
Sub edi,eax
mov ecx,edi
lea esi,S
lea edi,D
repe cmpsb

jz done
mov flag,0
done:

/*】*/
	}
	if(flag==0)
	  printf("不相等"); 
	else
	 printf("相等");
}

8.键盘输入一串字符给数组a和一个整数i,然后将字符串a中的字符向后移i个位置。
注意:前i个位置字符不变。

如:
运行后输入:ABCDEFGHIJKLMNOPQRSTUVWXYZ 10
则结果输出:ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ

#include "stdio.h"
void main()
{
char a[63];
int i;
scanf("%s %d",a,&i);
__asm
{
/*【*/
STD
lea esi,a+61
sub esi,i
lea edi,a+61
mov ecx,62
sub ecx,i
rep movsb
CLD

/*】*/
}
printf("%s",a);
}

9.键盘输入a和b两串字符,编程实现将a串和b串连接的结果存入字符数组c[50]并输出。
如:
运行后输入:ABCD abcd
则结果输出:ABCDabcd

#include "stdio.h"
#include "string.h"
void main()
{
char a[50]="ABCD",b[50]="abcd", c[50]={0};
int n,m;
scanf("%s %s",a,b);
n=strlen(a);m=strlen(b);
	__asm
	{
/*【*/
lea esi,a
lea edi,c
mov ecx,n
rep movsb

lea esi,b
lea edi,c
add edi,n
mov ecx,m
rep movsb

/*】*/
	}
	printf("%s",c);
}

10.键盘输入任一个整数n和一个汉字(即两个字符),然后用2n个汉字填充数组s[81]。
Input any integer n and one Chinese character (that is, one Chinese character occupies two characters) from the keyboard, and then fill the array s[81] with 2 times n Chinese characters.
如For example:
运行后输入After running, input:4 字
则结果输出Then output:字字字字字字字字

#include "stdio.h"
void main()
{
char a,b,s[81]={0};
int n;
scanf("%d %c%c",&n,&a,&b);
__asm
{
/*【*/
Cld
lea edi,s
mov al,a
mov ah,b
mov ecx,n
sal ecx,1
rep stosw
/*】*/
}
printf("%s",s);
}

11.键盘输入任一个整数n和一个两字词语(即4个字符),然后用2n个词语填充数组s[81]。
Input any integer n and a two-character Chinese words (occupying 4 characters) from the keyboard, and then fill the array s[81] with 2 times n Chinese words.
如For example:
运行后输入After running, input:4 汉字
则结果输出Then output:汉字汉字汉字汉字汉字汉字汉字汉字

#include "stdio.h"
void main()
{
char a,b,c,d,s[81]={0};
int n;
scanf("%d %c%c%c%c",&n,&a,&b,&c,&d);
__asm
{
/*【*/
Cld
lea edi,s
mov ecx,n
imul ecx,4
mov esi,0
mov ebx,2

again:
mov eax,esi
cdq
idiv ebx
cmp edx,0
JE Tag
mov al,c
mov ah,d
stosw
JMP DONE

Tag:
mov al,a
mov ah,b
stosw

DONE:
inc esi
LOOP again
/*】*/
}
printf("%s",s);
}

八、子程序(函数)

1.编一函数Max(int x,int y)用于求整数x和y中的最大值。
Write a function Max (int x, int y) to find the maximum value of integers x and y.
运行后输入Run the program and input:
4 5
则结果输出Output the result:
最大值为5
运行后输入Run the program and input:
5 4
则结果输出Output the result:
最大值为5

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
fmt	BYTE	'%d %d',0		;定义变量
fmt2	BYTE	'最大值为%d',0		;定义变量
x	DWORD	?
y	DWORD	?
.code				;⑥代码段
 ;**/
Max proc a:dword,b:dword
mov eax,a
.if eax<b
      mov eax,b
.endif
ret
Max endp

 ;**/
start:				;定义标号start
invoke scanf,ADDR fmt,ADDR x,ADDR y	;输入x和y的值
invoke Max,x,y
invoke printf,ADDR fmt2,EAX
RET		;退出
end	start			;指明程序入口点start

2.编一函数fun(int n)用于判断整数n是否是素数。
Write a function fun(int n) to determine whether the integer n is a prime number.
运行后输入Run the program and input:
5
则结果输出Output the result:
是素数
运行后输入Run the program and input:
4
则结果输出Output the result:
不是素数

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
fmt	BYTE	'%d',0		;定义变量
fmt2	BYTE	'%s',0		;定义变量
n	DWORD	0
s1	BYTE	'是素数',0
s2	BYTE	'不是素数',0
.code				;⑥代码段
 ;**/
fun proc a:dword
local x:dword
mov x,2
mov ecx,n

.while x<ecx
    mov eax,n
    cdq
    div x
    .if edx==0
        .break
    .endif
    inc x
.endw

mov ecx,n
.if x<ecx
    invoke printf,addr s2
.else
    invoke printf,addr s1
.endif

ret
fun endp
 ;**/
start:				;定义标号start
invoke scanf,ADDR fmt,ADDR n	;输入n的值
invoke fun,n
RET
end	start			;指明程序入口点start

3.编写一个子程序Upper,实现将小写字母变大写字母(不是小写字母不变)。
Write a subroutine named Upper to change lowercase letters to uppercase letters (leave the uppercase letters unchanged).
运行后输入Run the program and input:
d
则结果输出Output the result:
[d]大写为D
运行后输入Run the program and input:
B
则结果输出Output the result:
[B]大写为B

.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段
Infmt	BYTE	'%c',0		;定义变量
Outfmt	BYTE	'[%c]大写为%c',13,10,0
c1		BYTE	?
.code						;⑥代码段
 ;**/
Upper proc c2:dword
movzx eax,byte ptr c2
.if eax>='a' && eax<='z'
  sub eax,20H
.endif
RET
Upper endP


 ;**/
start:						;定义标号start
invoke scanf,ADDR Infmt,ADDR c1	;输入c1的值
invoke Upper,DWORD PTR c1	;求c1字符的大写通过EAX返回
invoke printf,ADDR Outfmt,DWORD PTR c1,EAX;输出
RET		;退出
end	start					;指明程序入口点start

4.编写子程序,类似C语言int SumN(int a[],int n)函数,求n个元素数组a中整数和并返回这个和。
Write a subroutine, similar to the C language function int SumN(int a[],int n), and obtain the integer sum in the n-element array a and return this sum.
运行后输入Run the program and input:
1 3 5
则结果输出Output the result:
和为9

.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段
a		DWORD	80 Dup(0) 	;定义数组a
Infmt	BYTE	'%d',0
Outfmt	BYTE	'和为%d',0
.code						;⑥代码段
 ;**/
SumN proc s:dword, n:dword
mov esi,0
mov eax,0
mov edx,s
.while esi<n
   add eax,[edx+esi*4]
   inc esi
.endw
RET
SumN endP


 ;**/
start:						;定义标号start
mov		ESI,0
invoke scanf,ADDR Infmt,ADDR a[ESI*4];输入a[i]的值
.while	EAX==1
INC		ESI
invoke scanf,ADDR Infmt,ADDR a[ESI*4];
.endw
invoke SumN,ADDR a,ESI		;求a数组和通过EAX返回
invoke printf,ADDR Outfmt,EAX;输出结果
RET	;退出
end	start					;指明程序入口点start

5.编一函数MinN(int a[],int n)用于求n个元素的数组a中的最小元素。
Write a function MinN(int a[],int n) to find the smallest element in an array a of n elements.
运行后输入Run the program and input:
1 3 4 5 2
则结果输出Output the result:
最小值为1
运行后输入Run the program and input:
7 3 6 4 5 8
则结果输出Output the result:
最小值为3

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
Infmt	BYTE	'%d',0
Outfmt	BYTE	'最小值为%d',0
a		DWORD	80 Dup(0) 	;定义数组a
.code				;⑥代码段
 ;**/
MinN proc x:dword, y:dword

mov esi,0
mov ebx,x
mov eax,[ebx+esi*4]

.while esi<y
      .if [ebx+esi*4]<eax
               mov eax,[ebx+esi*4]
     .endif
      inc esi
.endw

ret
MinN endp
 
 ;**/
start:				;定义标号start
mov		ESI,0
invoke scanf,ADDR Infmt,ADDR a[ESI*4];输入a[i]的值
.while	EAX==1
INC		ESI
invoke scanf,ADDR Infmt,ADDR a[ESI*4];
.endw
invoke MinN,ADDR a,ESI		;求a数组和通过EAX返回
invoke printf,ADDR Outfmt,EAX;输出结果
RET		;退出
end	start			;指明程序入口点start

6.编一串拷贝子程序,实现C语言char strcpy(char Dst,char Src)函数,然后主程序调用strcpy(s1,s2)实现s2串拷贝到s1串。
Write a string-copy subroutine to implement the C language function char
strcpy(char *Dst,char *Src), and then the main program calls strcpy(s1,s2) to copy the content of s2 string to that of the s1 string.
运行后输入Run the program and input:
ABCD
则结果输出Output the result:
ABCD

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
fmt	BYTE	'%s',0		;定义变量
s1	BYTE	80 Dup(0)
s2	BYTE	80 Dup(0)
.code				;⑥代码段
 ;**/
strcpy proc x:dword, y:dword
mov esi, y
mov edi, x    
mov ecx, 80
rep movsb
ret
strcpy endp

 ;**/
start:				;定义标号start
invoke scanf,ADDR fmt,ADDR s2	;输入s2的值
invoke strcpy,ADDR s1,ADDR s2	;求s2串拷贝到s1串
invoke printf,ADDR fmt,ADDR s1	;输出
invoke ExitProcess,0		;退出进程,返回值为0
end	start			;指明程序入口点start

7.编一串连接子程序,实现C语言char strcat(char Dst,char Src)函数,然后主程序调用strcat(s1,s2)实现s2串追加(连接)到s1串。
Write a string- concatenation subroutine to implement the C language function char
strcat (char *Dst, char *Src), and then the main program calls strcat (s1, s2) to implement the addition (concatenation) of the s2 string to the s1 string.
运行后输入Run the program and input:
AB CD
则结果输出Output the result:
ABCD

.386				;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none		;指明标识符大小写敏感
include	kernel32.inc		;要引用的头文件
includelib	kernel32.lib	;要引用的库文件
includelib	msvcrt.lib	;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data				;⑤数据段
fmt1	BYTE	'%s %s',0	;定义变量
fmt2	BYTE	'%s',0
s1	BYTE	80 Dup(0)
s2	BYTE	80 Dup(0)
.code				;⑥代码段
 ;**/
strcat proc str1:dword, str2:dword
mov esi, str2
mov edi, str1
mov eax,0

.while byte ptr[edi]!=0
      inc edi
.endw
.while byte ptr[esi]!=0
      inc esi
      add eax,1
.endw
CLD
mov esi,str2
mov ecx,eax
rep movsb
ret
strcat endp
 ;**/
start:				;定义标号start
invoke scanf,ADDR fmt1,ADDR s1,ADDR s2
invoke strcat,ADDR s1,ADDR s2	;求s2串连接到s1串
invoke printf,ADDR fmt2,ADDR s1;输出
invoke ExitProcess,0		;退出进程,返回值为0
end	start			;指明程序入口点start

8.编写子程序,类似C语言double MaxREAL(double a[],int n) 函数,求n个元素数组a中的最大值。
Write a subroutine, similar to the C language function double MaxREAL(double a[],int n), to find the maximum value of the n-element array a.
运行后输入Run the program and input:
1.1 3.2 5.2 2.1
则结果输出Output the result:
最大值为5.2

.386						;选择的处理器
.model flat, stdcall		;存储模型,Win32程序只能用平展(flat)模型
option casemap:none			;指明标识符大小写敏感
includelib	msvcrt.lib		;引用C库文件
scanf PROTO C:DWORD,:vararg	;C语言scanf函数原型声明
printf PROTO C:DWORD,:vararg	;C语言printf函数原型声明
.data						;⑤数据段
Infmt	BYTE	'%lf',0
Outfmt	BYTE	'最大值为%g',0
a		QWORD	80 Dup(0.0) 	;定义数组a
MaxR QWORD ?
.code						;⑥代码段
 ;**/
MaxREAL proc s:dword, n:dword

mov edx,s
FLD qword ptr [edx]
FSTP MaxR
mov ecx,n
Fless=1
Fequ=40h

.while ecx>0
      FLD MaxR
      Fcomp qword ptr [edx]
      Fnstsw ax
      .if ah&Fless
            FLD qword ptr [edx]
            FSTP MaxR
      .endif
      add edx,8
      dec ecx
.endw

FLD MaxR

ret
MaxREAL endp
 ;**/
start:						;定义标号start
mov		ESI,0
invoke scanf,ADDR Infmt,ADDR a[ESI*8];输入a[i]的值
.while	EAX==1
INC		ESI
invoke scanf,ADDR Infmt,ADDR a[ESI*8];
.endw
invoke MaxREAL,ADDR a,ESI		;求a数组和通过EAX返回
FSTP MaxR
invoke printf,ADDR Outfmt,MaxR;输出结果
RET	;退出
end	start					;指明程序入口点start

九、递归程序设计 Recursive Programming

1.编一函数fun(int n),用归递方法实现求1到n的累加和,运行后输入Run the program and input正整数n,输出该累加和。
Write a function fun(int n), use the recursive method to implement the cumulative sum of 1 to n, input a positive integer n after running, and output the cumulative sum.
运行后输入Run the program and input:
10
则结果输出Output the result:
55

.386	
.model flat, stdcall
option casemap:none	
includelib	msvcrt.lib
scanf PROTO C:DWORD,:vararg	
printf PROTO C:DWORD,:vararg	
.data			
fmt	BYTE	'%d',0	
N	DWORD	0
.code	
 ;**/
fun proc n:dword
.if n>1
   mov ecx,n
   dec ecx
   invoke fun, ecx
   add eax,n
.else
   mov eax,n
.endif
ret
fun endp

 ;**/
start:
invoke scanf,ADDR fmt,ADDR N;输入N
invoke fun,N 
invoke printf,addr fmt,eax
ret
end	start

2.用归递方法实现Hanoi(汉诺)塔问题。
Use the recursive method to implement the Hanoi Tower problem.

运行后若输入Run the program and input:
1
则结果输出Output the result:
A->C

运行后若输入Run the program and input:
2
则结果输出Output the result:
A->B
A->C
B->C

运行后若输入Run the program and input:
3
则结果输出Output the result:
A->C
A->B
C->B
A->C
B->A
B->C
A->C

.386
.model flat, stdcall
option casemap :none 
includelib	msvcrt.lib
printf PROTO C:ptr sbyte,:vararg
scanf PROTO C:ptr sbyte,:vararg
.data
fmt db '%d',0
fmt2 db '%c->%c',10,13,0
N dd ?
.code
 ;**/

fun proc n:dword, mark:dword, flag:dword, temp:dword

.if n<=1
     invoke printf, addr fmt2,mark,temp
.else
     mov ecx,n
     dec ecx
     invoke fun ,ecx,mark,temp,flag
     invoke printf, addr fmt2,mark,temp
     mov ecx,n
     dec ecx
     invoke fun ,ecx,flag,mark,temp
.endif

ret
fun endp


 ;**/
start:
invoke scanf,addr fmt,addr N
invoke fun,N,'A','B','C'
ret
end start 

3.设有一棵完全二叉树(该树除最低下一层右侧结点不存在,其它结点都存在),其每个结点的值都是一个字母。该二叉树各结点的值按层(同层的按从左到右的顺序)存储于字符数组B中,如下图字符数组B的值为“ABCDEFGHIJKLMNOPQRST”。
There is a complete binary tree (except that the node on the right side of the lowest level of the tree does not exist, other nodes exist), and the value of each node is a letter. The value of each node of the binary tree is stored in character array B by layer (from left to right in the same layer). The value of character array B in the following figure is “ABCDEFGHIJKLMNOPQRST”.

现要求编程输入字符数组B的值,然后按中序遍历输出各结点的值。
Now it is required to program input the value of character array B, and then traverse and output the value of each node in the middle order.
若运行后若输入Run the program and input:
ABCDEFG
则运行结果输出Output the result:
DBEAFCG

.386
.model flat, stdcall
option casemap :none
includelib	msvcrt.lib
printf PROTO C:ptr sbyte,:vararg
scanf PROTO C:ptr sbyte,:vararg
strlen PROTO C:ptr sbyte
.data
B db 80 dup(?)
fmt db '%s',0
fmt2 db '%c',0
fmt3 db '空二叉树',0
.code
 ;**/
fun proc b, i, n
.if n<=0
    invoke printf,addr fmt3
.else
     mov esi,i
     lea esi,[esi*2+1]
     .if esi<n
         invoke fun, b, esi, n
     .endif
     mov edx,b
     mov esi,i
     invoke printf, addr fmt2, dword ptr [edx+esi]
.endif

mov esi,i
lea esi,[esi*2+2]
.if esi<n
    invoke fun, b, esi, n
.endif
ret 
fun endp


 ;**/
start:
invoke scanf,addr fmt,addr B
invoke strlen,addr B
invoke fun,addr B,0,eax
ret
end start

4.设有一棵二叉树,其每个结点的值都是一个字母。该二叉树各结点的值按层(同层的按从左到右的顺序)存储于字符数组B中,如下图字符数组B的值为“ABCDEFGH^JK^MNOP^^^T”,其中“^”表示不存在的结点。
There is a binary tree, the value of each node is a letter. The value of each node of the binary tree is stored in character array B by layer (from left to right in the same layer). The value of character array B in the following figure is “ABCDEFGHJKMNOP^^^T”, where " ^" indicates a node that does not exist.

现要求编程输入字符数组B的值,然后按中序遍历输出各结点的值。
Now it is required to program input the value of character array B, and then traverse and output the value of each node in the middle order.
若运行后若输入Run the program and input:
ABCD^^G
则运行结果输出Output the result:
DBACG

.386
.model flat, stdcall
option casemap :none
include kernel32.inc
includelib kernel32.lib
includelib	msvcrt.lib		;引用C库文件
printf PROTO C:ptr sbyte,:vararg	;C语言printf函数原型声明
scanf PROTO C:ptr sbyte,:vararg	;C语言scanf函数原型声明
 ;**/
.data
infmt DB '%s',0
outfmt DB '%c',0
s DB 80 Dup(0)
flag DD 0

.code
inorder proc x:dword, len:dword
mov esi,x
.if esi<len
   mov eax,x 
   imul eax,2
   add eax,1
   invoke inorder ,eax,len
   mov esi,x
   .if s[esi]!='^'
      invoke printf,addr outfmt,s[esi]
   .endif
   mov eax,x
   imul eax,2
   add eax,2
   invoke inorder ,eax,len
.endif
ret
inorder endp
start:
invoke scanf,addr infmt,addr s
mov edi,0
.while s[edi]!=0
   inc edi
.endw
invoke inorder ,flag,edi
ret
end start

 ;**/

5.编一函数fun(int n),用归递方法实现将十进制数转换为二进制数,运行后输入Run the program and input正整数n,输出n的二进制数。
Write a function fun(int n), use the recursive method to convert the decimal number into a binary number. After running, enter the positive integer n and the word “Run the program and input”, and output the binary number of n.
运行后输入Run the program and input:
250
则结果输出Output the result:
11111010

.386
.model flat, stdcall
option casemap:none
includelib	msvcrt.lib
scanf PROTO C:DWORD,:vararg
printf PROTO C:DWORD,:vararg
.data
fmt	BYTE	'%d',0
N	DWORD	0
b	DWORD	2
.code
 ;**/
fun proc n
local x:dword,y:dword
mov x,2
.if n<2
   invoke printf, addr fmt,n
.else
   mov eax,n
   cdq
   div x
   mov y,edx
   invoke fun, eax
   invoke printf, addr fmt, y
.endif
ret
fun endp

 ;**/
start:
invoke scanf,ADDR fmt,ADDR N;输入N
invoke fun,N 
ret
end	start

/---------------以下类型题目,答题时不能存在空格-----------------/

十、浮点数表示

  1. 现要将 -13.5 表示成单精度机器数即 k=8,n=23,则该机器数对应尾数符号____B(1位,二进制),该机器数用移码表示的阶码为___________B(8位,二进制),用原码表示的尾数数值为_______________________________________B(23位,二进制)。
//因为 “换头没换衣服” 就直接写结果:
-13.5    1    1000 0010        101 1000000000 0000000000
+7.5     0    1000 0001        111 0000000000 0000000000
+14.5    0    1000 0010        110 1000000000 0000000000
-29.0    1    1000 0011        110 1000000000 0000000000
+28.0    0    1000 0011        110 0000000000 0000000000
-26.0    1    1000 0011        101 0000000000 0000000000

2.现要将 +29 表示成单精度机器数即 k=8,n=23,则该机器数对应的尾数符号为____B(1,二),该机器数对应的尾数真值(含符号)为______D(十),实际存储的尾数数值(不含符号)为_______D(十),用原码表示的尾数数值为___________________________B(23,二),该机器数用移码表示的阶码为___________B(8,二),该机器数对应的十六进制数值为__________H。

//答案在此
0    +1.8125    0.8125        110 1000000000 0000000000        1000 0011        41e80000
//因为 “换头没换衣服” 就直接写结果:
+250    +1.5625    0.5625      100 1000000000 0000000000        1000 0011        41c80000
+2640    +1.03125   0.03125     000 0100000000 0000000000        1000 0111        43840000
-661    -1.03125   0.03125     000 0100000000 0000000000        1000 0101        c2840000
-0.281251    -1.125     0.125       001 0000000000 0000000000        0111 1101        be900000
-0.1718751    -1.375     0.375       011 0000000000 0000000000        0111 1100        be300000
+280    +1.75      0.75        110 0000000000 0000000000        1000 0011        41e00000
+270    +1.6875    0.6875      101 1000000000 0000000000        1000 0011        41d80000

3.单精度机器数 k=8,n=23,现要将机器数 0 10000111 110 0000000000 0000000000 B转成实数,机器数对应的尾数符号为_____B(1,二),该机器数对应的尾数真值(含符号)为_____D(十),实际存储的尾数数值(不含符号)为_____D(十),该机器数对应的阶码为________B(8,二),该机器数对应的阶码真值为____D(是),该机器数对应的浮点数数值为_____D(十)。

0    +1.75     0.75     1000 0111     8    448
因为 “换头没换衣服” 就直接写结果:
// 0 01111001 111 0000000000 0000000000 B
0    +1.875    0.875    0111 1001    -6    0.0292969
// 1 10000100 111 0000000000 0000000000 B
1    -1.875    0.875    1000 0100     5    -60
// 1 01111011 111 0000000000 0000000000 B
1    -1.875    0.875    0111 1011    -4    -0.1171875
// 0 10000110 111 0000000000 0000000000 B
0    +1.875    0.875    1000 0110     7    240
// 1 01111111 101 1000000000 0000000000 B
1    -1.6875   0.6875   0111 1111     0    -1.6875

4.现要将 -0.375 表示成单精度机器数即 k=8,n=23,则该机器数对应的尾数符号为_____B(1,二),该机器数对应的尾数真值(含符号)为_____D(十),实际存储的尾数数值(不含符号)为_____D(十),用原码表示的尾数数值为_______________________________B(23,二),该机器数用移码表示的阶码为________B(8,二),该机器数对应的十六进制数值为__________H。

1    -1.5    0.5    100 0000000000 0000000000    0111 1101    BEC0 0000

5.单精度机器数 k=8,n=23,现要将机器数 0 10000010 101 0000000000 0000000000 B转成实数,机器数对应的尾数符号为_____B(1,二),该机器数对应的尾数真值(含符号)为_____D(十),实际存储的尾数数值(不含符号)为_____D(十),该机器数对应的阶码为________B(8,二),该机器数对应的阶码真值为____D(十),该机器数对应的浮点数数值为_____D(十)。

0    1.625    0.625    1000 0010    3    13

草稿留底,以便回忆。

十一、CPU与存储器连接CPU

1.假设 EAX = 12345678H,EBX = 11223344H,[11223344H] = 87654321H,MOV EAX,[EBX],AL = ____H,AH = ____H,AX = ____H,EAX = __________H,EBX = __________H。

//答案在此
21		43		4321		87654321		11223344
//类似题型(答案就不写了):
8765432111223344[11223344]=12345678,eax,[ebx]1122334487654321[87654321]=44332211,eax,[ebx]1122334487654321[11223344]=13245768,ebx,[eax]

2.如图(一般题目都会给,翻开我的课本P66可见),mov dword ptr ds:[00445568H],16385a7bH 时,D31 ~ D0 引脚值为_______H(8位 十六进制),A31 ~ A2 引脚为________________________________________B(30,二),BE3 ~ BE0(编辑限制,别介)引脚值______B(4,二),W / R 引脚值为____B(1,二),M / IO 引脚值为____B(1,二),D / C 引脚值为____B(1,二)。

//答案在此
16385a7b		0000 0000 0100 0100 0101 0101 0110 10		0000		1		1		1
类似题型:
//mov eax,dword ptr ds:[00503074 H],eax = 7364A3B4 H,......
7364A3B4		0000 0000 0101 0000 0011 0000 0111 01		0000		1		1		112/10分?)
//mov word ptr ds:[0040302A H],5321 H时,D31~D6引脚......
5321		0000 0000 0100 0000 0011 0000 0010 10		0011		1		1		1
//mov AX,word ptr ds:[00403028 H]后,eax = 3642C7D8 H,D15~D0为......
C7D8		0000 0000 0100 0000 0011 0000 0010 10		1100		0		1		1
//mov dword ptr ds:[00443324H],11335577H
11335577    0000 0000 0100 0100 0011 0011 0010 01       0000		1		1		1
//mov dword ptr ds:[00403028H],10204080H       
10204080    0000 0000 0100 0000 0011 0000 0010 10       0000		1		1		1
//mov word ptr ds:[00403026H],1234H
1234        0000 0000 0100 0000 0011 0000 0010 01       0011		1		1		1
//mov word ptr ds:[0040302CH],3547H
3547        0000 0000 0100 0000 0011 0000 0010 11       1100		1		1		1
//mov AX,word ptr ds:[0040302C H],...EAX=31425768 H,...
5768        0000 0000 0100 0000 0011 0000 0010 11       1100		0		1		1
//mov EAX,dword ptr ds:[00403024 H],...EAX=33445364 H,...
33445364    0000 0000 0100 0000 0011 0000 0010 01       0000		0		1		1

3.mov dword ptr ds: [0040702D H],A1B2C3D4 H。分两次传输,第一次传输时,D31 ~ D0 为__________H(8,十六;不确定的位用 “X” 表示),A31 ~ A2引脚值为________________________________________B(30,二),BE3 ~ BE0 引脚值______B(4,二);第二次传输时,D31 ~ D0 为__________H(8,十六;不确定的位用 “X” 表示),A31 ~ A2引脚值为________________________________________B(30,二),BE3 ~ BE0 引脚值______B(4,二)。

//答案在此
B2C3D4XX		0000 0000 0100 0000 0111 0000 0010 11		0001		XXXXXXA1		0000 0000 0100 0000 0111 0000 0011 00		1110
类似题目
//mov dword ptr ds:[00407026 H],C1D2A3B4 H时,......
A3B4XXXX		0000 0000 0100 0000 0111 0000 0010 01		0011		XXXXC1D2		0000 0000 0100 0000 0111 0000 0010 10		1100
//mov dword ptr ds:[00403026 H],11223344 H时,......
3344XXXX        0000 0000 0100 0000 0011 0000 0010 01		0011		XXXX1122		0000 0000 0100 0000 0011 0000 0010 10		1100
//mov dword ptr ds:[00403027 H],11223344 H时,......
44XXXXXX        0000 0000 0100 0000 0011 0000 0010 01		0111		XX112233		0000 0000 0100 0000 0011 0000 0010 10		1000
//mov dword ptr ds:[00403025 H],11223344 H时,......
223344XX        0000 0000 0100 0000 0011 0000 0010 01		0001		XXXXXX11		0000 0000 0100 0000 0011 0000 0010 10		1110

十二、CPU设计与IO系统CPU

1.根据控制器设计方法不同,可分为三类,其中采用 门电路 实现的是( B )

A.存储逻辑型控制器 Storage Logic Controller                                //采用微指令实现,把微操作信号代码化;便于调试、维修及更改、扩充指令;
B.组合逻辑型...... Combination Logic Controller                            //
C.前两者结合型.... Combination Logic and Storage Logic Combined Controller //速度最快但难以实现;设计自动化;
D.集成电路型...... Integrated Circuit Controller                           //

2.已知某些汇编指令与机器码的清单如下:

第一行 数据为例分析:

根据以上信息,寄存器EDX 的地址编码是______B(3位,二进制),指令 “MOV EBX,EAX” 机器码依次是______H(2,十六)和______H(2,十六),机器码 8B H 和 E3 H 对应的汇编指令是____________。

//答案在此
010		8B		D8		mov esp,ebx
 “换汤不换药”
//寄存器ESP... MOV ESI,ESP... 8BH 和ECH
100		8B		F4		mov ebp,esp

3.一个指令周期由若干个____________组成。
4.32位CPU中存储正在执行指令的的下一条指令的地址是____________。
5.通过CPU查看外设是否有数据然后再进行数据传输的工作方式是________________________。
6.通过CPU发出数据传输要求,然后由专门部件实现,不需要CPU完成数据传输完的善后的工作方式是____________方式。
7.一个机器周期一般由1个____________组成,4个____________组成。
8.当外设需要进行输入输出数据,通过产生请求信号向CPU反馈以便决定是否进行传输,这种工作方式是____________方式。
9.比较指令 “cmp x, 60” 执行后,是否相等的状态值存储于____________寄存器中。
10.16位CPU中存储正在执行指令的下一条指令的地址是_______。
11.8位CPU中存储正在执行指令的下一条指令的地址是_______。
12.存储正在读取指令/数据的地址的是_______。
13.存储正在译码的指令的寄存器是_______。
14.存储指令执行结果状态的寄存器是_______。
15.通过CPU发出数据传输来源和目的地址及数量,然后由专门部件实现,数据传输完后CPU再善后的工作方式是_______方式。

//答案
3.机器周期 machine cycle
4.EIP
5.程序查询 Program quary
6.I/O通道 I/O channel
7.CPU周期 CPU cycle;时钟周期 Clock cycle
8.中断 Interruption
9.PSW
10.IP
11.PC
12.MDR
13.IR
14.PSW
15.DMA

16.若某指令系统使用 两字节 作为指令的机器码,其中 0~2 位作为源操作数的地址, 3~5 位作为目的操作数的地址,则该指令系统至多有_______条不同的指令。

//答案
1024
解析:“两字节” = 16位,“0~2” 和 “3~5” 共占了6位,剩余10位,即2^10=1024
 “换汤不换药”
//2字节;0~2;即2^13
8192
//2字节;0~3;即2^12
4096
//2字节;0~3,4~7;即2^8
256
//1字节;0~2;即2^5
32
//1字节;0~3;即2^4
16
//1字节;0~4;即2^3
8
//1字节;0~5;即2^2
4

17.某存储芯片标示 4K * 4 ,则表示该芯片有____________。

//答案
12根地址,4根数据
 “换汤不换药”
//2k*8
118//1k*8
108//4k*8
12   8
//8k*8
13   8
//16k*8
14   8
//16k*4
14   4

十三、校验码 Check Code

1.假如海明校验法中 4位校验码 P1P2P4P8 和 7位有效信息位 A6A5A4A3A2A1A0 位置关系为 P1P2A6P4A5A4A3P8A2A1A0。若字母 ‘M’ 的ASCII是 100 1101B,则它的 4位海明校验码位(偶校验)是________B(4,二),海明校验码(偶校验)是______________B(11,二)

//答案
0110	0111 0010 101
“换汤不换药”
//...若字母 ‘M’ 的ASCII是 101 1001B...
1001	1010 0111 001
//...若接收到的海明校验码(偶校验)是1011 0011 100 B,则该校验码第_____位有错(填0~11,没错填0),有效字符编码是____________B(7,二)
0		1001 100

2.设生成多项式为G(x) = x^3 + x^1 + 1,生成的多项式对应的二进制为_________B,4位有效二进制信息 1001 B对应的 7位 CRC为

//答案
1011	100 1110 
“换汤不换药”
//...G(x) = x^3 + x^2 + 1... 0011 B对应的... 
1101	001 1010
//...则若接收到的7位CRC码为100 1100,用G(x)做 模2除,得到的三位余数为______B,说明传输数据_______(填 “有错”[指余数≠0] 或 “没错”)
010		有错
//...G(x) = x^3 + x^2 + 1,则若接收到的7位CRC码为100 0001,用G(x)做 模2除,...
111		有错

3.假如海明校验法中 4位校验码 P1P2P4P8 和 7位有效信息位 A6A5A4A3A2A1A0 位置关系为 P1P2A6P4A5A4A3P8A2A1A0。若 接收到的海明校验码位(偶校验)是 0111 0010 001 B,则该校验码第________位有错(回答0~11,没错答0),有效字符编码是____________B(7,二)

//答案
9		1001 101
  1. 字符 “A” 的7位二进制数为100 0001B,若数据传输时用 奇校验 ,则对应编码为________________B,若用 偶校验 ,则为________________B。
//答案
1100 0001		0100 0001
“换汤不换药”
//"J" 的7位二进制数为100 1010B...
0100 1010		1100 1010


上述乃平时习题

十四、考试测试题

循环结构

在这里插入代码片

递归

1.编写一个求排序组合数的函数 int Com(int N, int M),该函数表示从N个元素中任意选择M个元素的组合数,可用如下公式表示(式中C上m下n表示 Com(N, M)):

运行后输入:6 2,则结果输出:15

com porc x:dword,y:dword
local t:dword
mov ebx,y
.if ebx==1
	mov eax,x
.else if ebx==x
	mov eax,1
.else
	mov ebx,x
	dec ebx
	mov ecx,y
	dec ecx
	invoke Com,ebx,ecx;b[-1]
	mov t,eax
	mov ebx,x
	dec ebx
	mov ecx,y
	invoke Com,ebx,ecx
	add t,eax
	mov eax,t
.endif
ret
Com endp

十五、OD吾爱破解软件

PW文件:/download/weixin_45308154/85776674 含部分答案

//查找方法
1. F8键按到底,确认地址;
2. 进入地址;
3. F8键按到底,输入密码;
4. 从最近的一个 call 进入;
5. 进入 pop 前面的call;
6. 再次进入 pop 前面的call;
7. 答案就在第二个call。

更新仍在继续…

⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱嘿嘿都看到这儿了~
⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱⋱↓点赞 ↓收藏 ↓打赏 三连 (#^ ^#) ❤不过分吧

发布评论

评论列表 (0)

  1. 暂无评论