怎样解读一段汇编程序
学习汇编有一段时间了 但是从书本上只学到一些基本的知识点 但对于一段汇编始终没有一个更整体和深刻的理解
所以 给出一段简单的汇编程序 望各位高手 结合自己在实践中的一些体会和给出的程序发表点个人观点 谢谢了
; Simple Arithmetic
; This program demonstrates some simple arithmetic instructions.
.386 ;So we can use extended registers
option segment:use16 ; and addressing modes.
dseg segment para public 'data'
; Some type definitions for the variables we will declare:
uint typedef word ;Unsigned integers.
integer typedef sword ;Signed integers.
; Some variables we can use:
j integer ?
k integer ?
l integer ?
u1 uint ?
u2 uint ?
u3 uint ?
dseg ends
cseg segment para public 'code'
assume cs:cseg, ds:dseg
Main proc
mov ax, dseg
mov ds, ax
mov es, ax
; Initialize our variables:
mov j, 3
mov k, -2
mov u1, 254
mov u2, 22
; Compute L := j+k and u3 := u1+u2
mov ax, J
add ax, K
mov L, ax
mov ax, u1 ;Note that we use the "ADD"
add ax, u2 ; instruction for both signed
mov u3, ax ; and unsigned arithmetic.
; Compute L := j-k and u3 := u1-u2
mov ax, J
sub ax, K
mov L, ax
mov ax, u1 ;Note that we use the "SUB"
sub ax, u2 ; instruction for both signed
mov u3, ax ; and unsigned arithmetic.
; Compute L := -L
neg L
; Compute L := -J
mov ax, J ;Of course, you would only use the
neg ax ; NEG instruction on signed values.
mov L, ax
; Compute K := K + 1 using the INC instruction.
inc K
; Compute u2 := u2 + 1 using the INC instruction.
; Note that you can use INC for signed and unsigned values.
inc u2
; Compute J := J - 1 using the DEC instruction.
dec J
; Compute u2 := u2 - 1 using the DEC instruction.
; Note that you can use DEC for signed and unsigned values.
dec u2
Quit: mov ah, 4ch ;DOS opcode to quit program.
int 21h ;Call DOS.
Main endp
cseg ends
sseg segment para stack 'stack'
stk byte 1024 dup ("stack ")
sseg ends
zzzzzzseg segment para public 'zzzzzz'
LastBytes byte 16 dup (?)
zzzzzzseg ends
end Main