80X86汇编语法笔记

主要看了一下汇编的语法知识,指令算比较熟悉了


一点笔记贴上来


80X86汇编学习笔记

代码
====================================================
; Example: Hello World
; Author GYARMY
; Date: 2018-4-10
.386
.MODEL FLAT

ExitProcess PROTO stdcall, dwExitCode:DWORD

.STACK 4096

.DATA
msg BYTE "Hello World",0

.CODE
_start:
INVOKE ExitProcess,0
PUBLIC _start
END _start
====================================================

编译与链接
ml /c /coff hello.asm
link /subsystem:console /entry:start /out:hello.exe hello.obj io.obj Kernel32.lib


======================C语言==================

;>>>>>>>>>>>>>>>>>>>>
;指令的工作模式
;>>>>>>>>>>>>>>>>>>>>
.386
.model flat

;>>>>>>>>>>>>>>>>>>>>
;include 包含文件
;>>>>>>>>>>>>>>>>>>>>
includelib Kernel32.Lib
includelib msvcrt.Lib

;>>>>>>>>>>>>>>>>>>>>
;函数说明
;>>>>>>>>>>>>>>>>>>>>
ExitProcess PROTO stdcall, dwExitCode:DWORD
printf PROTO c : ptr sbyte, : vararg

;>>>>>>>>>>>>>>>>>>>>
;stack
;>>>>>>>>>>>>>>>>>>>>
stack segment
 db 100 dup(?)
stack ends


;>>>>>>>>>>>>>>>>>>>>>
;data
;>>>>>>>>>>>>>>>>>>>>>
data segment
msg db "Hello World",0
data ends

;>>>>>>>>>>>>>>>>>>>>>
;code
;>>>>>>>>>>>>>>>>>>>>>
code segment 

_start:
invoke printf, offset msg
invoke ExitProcess,0

public _start

code ends
end _start

======================C语言==================

改进的写法


==========================================
;>>>>>>>>>>>>>>>>>>>>
;指令的工作模式
;>>>>>>>>>>>>>>>>>>>>
.386
.model flat

;>>>>>>>>>>>>>>>>>>>>
;include 包含文件
;>>>>>>>>>>>>>>>>>>>>
includelib Kernel32.Lib
includelib msvcrt.Lib

;>>>>>>>>>>>>>>>>>>>>
;函数说明
;>>>>>>>>>>>>>>>>>>>>
ExitProcess PROTO stdcall, dwExitCode:DWORD
printf PROTO c : ptr sbyte, : vararg

;>>>>>>>>>>>>>>>>>>>>
;stack
;>>>>>>>>>>>>>>>>>>>>
.stack 100
;>>>>>>>>>>>>>>>>>>>>>
;data
;>>>>>>>>>>>>>>>>>>>>>
.data
msg db "Hello World",0


;>>>>>>>>>>>>>>>>>>>>>
;code
;>>>>>>>>>>>>>>>>>>>>>
.code

_start:
invoke printf, offset msg
invoke ExitProcess,0

public _start

end _start

==================================================

==================================================
.386
.model flat

includelib Kernel32.Lib
includelib msvcrt.Lib

ExitProcess proto stdcall, dwExitCode:DWORD
printf proto c : ptr sbyte, : vararg

.stack 100

.data
a dword 9
b dword 26
m   dword ?
n dword ?
fmt byte "%d",13,10,0

.code 
_start:
mov eax,a
add eax,b
mov m,eax
mov eax,12
add eax,88
mov n,eax
mov eax,m
invoke printf, offset fmt,eax
mov eax,n
invoke printf, offset fmt,eax
invoke ExitProcess,0

public _start

end _start
==================================================

使用masm32

.386
.model flat
option casemap:none
option language:c

include     windows.inc
include     kernel32.inc
include     user32.inc
includelib     user32.lib
includelib     kernel32.lib

.data
msg        byte     "Hello World",0
cap        byte     "输出",0

.code
start:
            invoke  MessageBox,
                    NULL,
                    offset msg,
                    offset cap,
                    MB_OK

            invoke  ExitProcess,0

public      start
            end start

==================================================
; 生成清单文件
ml /c /coff /Fl demo2.asm
==================================================
.386
.model flat

ExitProcess proto near32 stdcall, dwExitCode:DWORD
.stack 4096

.data
number dword -105
sum dword ?

.code
_start:
mov eax,number
add eax,158
mov sum,eax
invoke ExitProcess,0
public _start
end _start
==================================================

各种指令 跳转
汇编的基础
跳着在看
==================================================

内联汇编
__asm{
mov eax,myValue
}



原文链接: 80X86汇编语法笔记 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://gyarmy.com/post-432.html )

发表评论

0则评论给“80X86汇编语法笔记”