求汇编小程序,二十行以上

来源:百度知道 编辑:UC知道 时间:2024/06/21 02:18:59
一定要能运行的啊,从网上下的执行的时候都报同样的错。难道是编译环境不对?大家都用什么工具啊?
不好意思啊,只要32位的汇编程序,就是开头有.386 modelflat stdcall .casemap none 等等的那种程序,谢谢啊
功能不用很强大的O(∩_∩)O~

.386
.model flat, stdcall
option casemap:none ; 大小写敏感

include kernel32.inc
include tutorial.inc
includelib kernel32.lib
includelib tutorial.lib

.data
var1 dword 11111234 ;需要初始化的数据定义
var2 dword 11111233

addition PROTO stdcall :dword, :dword

.code
start:
invoke addition, var1, var2 ; 使用invoke来调用子程序

push eax
call PrintUInt ; 打印和

invoke ExitProcess, 0 ; 退出程序

;
; procedure name: addition
; function: add 2 32bit unsigned numbers
; input: 2 32bits numbers on stack
; output: eax stores the sumary
;
addition PROC stdcall num1:dword, num2:dword ;子函数,实现两个无符号32位数相加
LOCAL sum:dword

mov edx, num1
add edx, num2
mov sum, edx ; 和保存在局部变量中,演示局部变量的用法

mov eax, edx ; 和保存在eax中返回
ret ; 子程序返回
addition ENDP
END start

0F92:0100 mov ah,1 ;选择DOS API的0