当前位置:网站首页>Assembly: code examples
Assembly: code examples
2022-06-10 03:48:00 【Melon seeds 300g】
List of articles
Example 1: Print Hello World
; Remind developers of the meaning of each paragraph
assume cs:code, ds:data
; ----- Data segment begin -----
data segment
age db 20h ;db: Represents a byte
no dw 30h ;dw: For two bytes
db 10 dup(6) ; Generate 10 A continuous 6
hello db 'Hello World!$'
data ends
; ----- Data segment end -----
; ----- Code segment begin -----
code segment
start:
; Manual settings ds Value
mov ax, data
mov ds, ax
mov ax, no
mov bl, age
; Print
mov dx, offset hello
; offset hello: representative hello The offset address of
mov ah, 9h
int 21h
; sign out
mov ax, 4c00h
int 21h
code ends
; ----- Code segment end -----
; End of compilation ,start It's the program entrance
; start The segment is the code segment
; therefore cs The value is code Segment address of the segment
; amount to cs The value of has been automatically set
end start
Example 2:ax,bx Data exchange
assume cs:code, ds:data, ss:stack
; --------- Stack segment ---------
stack segment
db 10 dup(8)
stack ends
; --------- Data segment ---------
data segment
db 20 dup(9)
data ends
; --------- Code segment ---------
code segment
start:
; Manual settings ss and ds
mov ax, stack
mov ss, ax
mov ax, data
mov ds, ax
mov ax, 1122h
mov bx, 3344h
; Use stack
mov sp, 10
push ax
push bx
pop ax
pop bx
; sign out
mov ax, 4c00h
int 21h
code ends
end start
边栏推荐
猜你喜欢
随机推荐
Implementation scheme of shared file
[paper notes | deep reading] struc2vec: learning node representations from structural identity
C language question brushing series (III)
[mysql] database - View
答辩前电脑坏了......
C 11 new feature: List pattern matching
Talk about 10 tips to ensure thread safety
RPC 实战与核心原理-进阶篇笔记
Yolov5 target detection neural network -- calculation principle of loss function
Distributed current limiting: current limiting based on sentinel implementation (I) - Overview
【TFLite, ONNX, CoreML, TensorRT Export】
【TFLite, ONNX, CoreML, TensorRT Export】
Redis 核心技术与实战-实践篇读书笔记 20~终结
【主流Nivida显卡深度学习/强化学习/AI算力汇总】
【比特熊故事汇】X Microsoft Build 2022——微软专家+MVP,技术亮点全解析
Keyword classification and the first C program
SSTI(模板注入) ——(7)
Opencv_ 100 questions_ Chapter I (1-5)
工作8年月薪8000四年未涨,跳槽拿15000,原老板招不到人苦求回去
[MySQL] 数据库-视图









