Win32彙編 MASM函式
阿新 • • 發佈:2018-12-13
題目1:
;*【*/ .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 x QWORD ? a QWORD ? b QWORD ? d QWORD ? z QWORD ? t QWORD ? h QWORD 2.0 intftm BYTE '%lf',0 outftm BYTE '%.2lf',0 .code start: invoke scanf,ADDR intftm,ADDR x FLD x FMUL x FSTP a FLD x FCOS FADD h;2.0 FSTP d FLD x FSIN FDIV d FADD a FSTP t FLD t FSQRT FSTP z invoke printf,ADDR outftm,z invoke ExitProcess,0 end start ;*】*/
題目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 a QWORD ? n QWORD ? r QWORD ? r1 QWORD ? r2 QWORD ? z QWORD ? z1 QWORD ? z2 QWORD ? y QWORD 1.0 fmt BYTE '%lf %lf',0 fmt2 BYTE '%.2lf',0 .code start: invoke scanf,ADDR fmt,ADDR a,ADDR n FLD n FLD a FYL2X FSTP r FLD y FLD r FPREM FSTP r1;小數部分 FLD r FSUB r1 FSTP r2;整數部分 FLD r1;小數部分F2XM1 F2XM1 FADD y FSTP z FLD r2; 整數部分 FLD y FSCALE FSTP z1 FLD z FMUL z1 FSTP z2 invoke printf,ADDR fmt2,z2 invoke ExitProcess,0 end start ;*】*/
題目3:
;*【*/ .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 x QWORD ? y QWORD 1.0 z QWORD ? fmt BYTE '%lf',0 fmt2 BYTE '%.3lf',0 .code start: invoke scanf,ADDR fmt,ADDR x FLD x F2XM1 FADD y FSTP z invoke printf,ADDR fmt2,z invoke ExitProcess,0 end start ;*】*/
題目4:
;*【*/
.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
x QWORD ?
y QWORD ?
z QWORD ?
z1 QWORD ?
a QWORD 180.0
b QWORD 3.1415926
ftm BYTE '%lf %lf',0
ftm2 BYTE '%g',0
.code
start:
invoke scanf,ADDR ftm,ADDR x,ADDR y
FLD y
FLD x
FPATAN
FSTP z
FLD z
FMUL a
FDIV b
FSTP z1
invoke printf,ADDR ftm2,z1
invoke ExitProcess,0
end start
;*】*/
題目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
x QWORD ?
y QWORD 1.0
z QWORD ?
intftm BYTE '%lf',0
outftm BYTE '%g %g',0
.code
start:
invoke scanf,ADDR intftm,ADDR x
FLD y
FLD x
FPREM
FSTP z
FLD x
FSUB z
FSTP x
invoke printf,ADDR outftm,x,z
invoke ExitProcess,0
end start
;*】*/
題目6:
;*【*/
.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
a QWORD ?
n QWORD ?
z QWORD ?
fmt BYTE '%lf %lf',0
fmt2 BYTE '%g*2^%g=%g',0
.code
start:
invoke scanf,ADDR fmt,ADDR a,ADDR n
FLD n
FLD a
FSCALE
FSTP z
invoke printf,ADDR fmt2,a,n,z
invoke ExitProcess,0
end start
;*】*
題目7:
;*【*/
.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 ;⑤資料段
a QWORD ?
x QWORD ?
z QWORD ?
z1 QWORD ?
z2 QWORD ?
g QWORD 1.0
h QWORD 10.0
Infmt byte '%lf %lf',0
Outfmt byte '%g',0
.code
start:
invoke scanf,addr Infmt,addr a,addr x
fld a
fld x
fyl2x
fstp z
fld g
fld h
fyl2x
fstp z1
fld z
fdiv z1
fstp z2
invoke printf,addr Outfmt,z2
invoke ExitProcess,0 ;退出程序,返回值為0
end start
;*】*/