MASM函数
键盘输入实数v和整数n的值,求u=v2n的值: 运行后若输入:1.5 3 则结果输出: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
infmt BYTE '%lf %lf',0
outfmt BYTE '%g*2^%g=%g',13,10,0
x QWORD ?
y QWORD ?
an QWORD ?
bn QWORD ?
anw QWORD ?
.code
start:
invoke scanf,ADDR infmt,ADDR x,ADDR y
FLD y
FLD x
FSCALE
FSTP anw
invoke printf,ADDR outfmt,x,y,anw
invoke ExitProcess,0
end start
;*】*/
键盘输入实数x的值,求如下表达式的值(保留2位小数): 运行后若输入:0.5 则结果输出:0.65 请在;【 /和;】 /之间编写程序
;*【*/
.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
infmt BYTE '%lf',0
outfmt BYTE '%.2lf',13,10,0
x QWORD ?
an QWORD ?
bn QWORD ?
cn QWORD ?
dn QWORD 2.0
anw QWORD ?
.code
start:
invoke scanf,ADDR infmt,ADDR x
FLD x
FMUL x
FSTP an
FLD x
FSIN
FSTP bn
FLD x
FCOS
FADD dn
FSTP cn
FLD bn
FDIV cn
FADD an
FSQRT
FSTP anw
invoke printf,ADDR outfmt,anw
invoke ExitProcess,0
end start
;*】*/
键盘输入实数y和实数x的值,求q=ylg(x)的值(用%g格式显示): 运行后若输入:0.5 10 则结果输出:0.5 运行后若输入:1.5 0.1 则结果输出:-1.5 请在;【 /和;】 /之间编写程序
;*【*/
.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
infmt BYTE '%lf %lf',0
outfmt BYTE '%g',13,10,0
x QWORD ?
y QWORD ?
an QWORD ?
bn QWORD 10.0
cn QWORD ?
anw QWORD ?
.code
start:
invoke scanf,ADDR infmt,ADDR y,ADDR x
FLD y
FLD x
FYL2X
FDIV y
FSTP an
FLD y
FLD bn
FYL2X
FDIV y
FSTP cn
FLD an
FDIV cn
FMUL y
FSTP anw
invoke printf,ADDR outfmt,anw
invoke ExitProcess,0
end start
;*】*/
键盘输入实数q,求实数q的整数部分n和小数部分p并输出(用%g格式输出): 运行后若输入:4.0 则结果输出:4 0 运行后若输入:4.1 则结果输出:4 0.1 运行后若输入:4.9 则结果输出:4 0.9 运行后若输入:-4.0 则结果输出:-4 -0 运行后若输入:-4.1 则结果输出:-4 -0.1 运行后若输入:-4.9 则结果输出:-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
infmt BYTE '%lf ',0
outfmt BYTE '%g %g',13,10,0
x QWORD ?
y QWORD 1.0
an QWORD ?
bn QWORD ?
cn QWORD ?
anw_1 QWORD ?
anw_2 QWORD ?
.code
start:
invoke scanf,ADDR infmt,ADDR x
FLD y
FLD x
FPREM
FSTP anw_2
FLD x
FSUB anw_2
FSTP anw_1
invoke printf,ADDR outfmt,anw_1,anw_2
invoke ExitProcess,0
end start
;*】*/
键盘输入实数x和实数y的值,求W=xy的值(保留2位小数)。 提示: 先求指数 ,再求出q的整数n和小数p,然后求v=2p,最后求w=v2n。 运行后若输入:0.5 2 则结果输出:0.25 运行后若输入:4 2 则结果输出: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
infmt BYTE '%lf %lf',0
outfmt BYTE '%.2lf',13,10,0
x QWORD ?
y QWORD ?
z QWORD 1.0
an QWORD ?
bn QWORD ?
cn QWORD ?
dn QWORD ?
en QWORD ?
anw QWORD ?
.code
start:
invoke scanf,ADDR infmt,ADDR x,ADDR y
FLD y
FLD x
FYL2X
FSTP an
FLD z
FLD an
FPREM
FSTP dn
FSTP z
FLD an
FLD z
FSCALE
FSTP en
FSTP an
FLD dn
F2XM1
FADD z
FSTP anw
FLD anw
FMUL en
FSTP anw
invoke printf,ADDR outfmt,anw
invoke ExitProcess,0
end start
;*】*/
键盘输入实数p(p介于-1~1之间)的值,求v=2p的值(保留3位小数): 运行后若输入:0.5 则结果输出:1.414 运行后若输入:1 则结果输出:2.000 运行后若输入:-1 则结果输出: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
infmt BYTE '%lf',0
outfmt BYTE '%.3lf',13,10,0
x QWORD ?
y QWORD 1.0
anw QWORD ?
.code
start:
invoke scanf,ADDR infmt,ADDR x
FLD y
FLD x
F2XM1
FADD y
FSTP anw
invoke printf,ADDR outfmt,anw
invoke ExitProcess,0
end start
;*】*/
前进的方向角(角度)。输入x和y值,用反正切函数指令(FPATAN)求角度。 运行后若输入:1.0 1.0 则结果输出:45 运行后若输入:-1.0 1.0 则结果输出:135 运行后若输入:1.0 -1.0 则结果输出:-45 运行后若输入:-1.0 -1.0 则结果输出:-135 请在;【 /和;】 /之间编写程序。
;*【*/
.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
infmt BYTE '%lf %lf',0
outfmt BYTE '%g',13,10,0
x QWORD ?
y QWORD ?
z QWORD 180.0
pi QWORD 3.1415926
an QWORD ?
bn QWORD ?
cn QWORD ?
anw QWORD ?
.code
start:
invoke scanf,ADDR infmt,ADDR x,ADDR y
FLD y
FLD x
FPATAN
FSTP an
FSTP bn
FLD z
FDIV pi
FSTP bn
FLD an
FMUL bn
FSTP anw
invoke printf,ADDR outfmt,anw
invoke ExitProcess,0
end start
;*】*/
after all