实验4 汇编应用编程和c语言程序反汇编分析
2021-03-11 09:32
标签:src 信息 c语言程序 源代码 复习 原理 传递 初始 入口 高级语言的参数传递是通过寄存器实现的,这里可以看到b先入栈然后是a,所以是从右往左入栈,通过call命令调用sum函数 这是通过访问x和y的内存数据实现相加的操作将结果存放在ax中返回主函数 实验4 汇编应用编程和c语言程序反汇编分析 标签:src 信息 c语言程序 源代码 复习 原理 传递 初始 入口 原文地址:https://www.cnblogs.com/sabertooth/p/14119948.htmlassume cs:code, ds:data
data segment
db ‘welcome to masm!‘
db 00000010B ;黑底绿字
db 00100100B ;绿底红字
db 01110001B ;白底蓝字
data ends
code segment
start:
mov ax,data
mov ds,ax ;ds指向字符串位置
mov ax,0B872h
mov es,ax ;es指向初始行列位置
mov cx,3 ;设置外层3次循环
mov bx,16 ;存储外层循环次数
external: push cx
mov di,0 ;存储内层循环次数
mov si,0 ;存储行列信息
mov cx,16 ;设置内层16次循环
internal: mov al,ds:[di] ;低位字节存放字符信息
mov ah,ds:[bx] ;高位字节存放颜色信息
mov es:[si],ax ;将字符和颜色信息移至需要的显存区
inc si
inc si ;向后推进2个字节
inc di ;向后推进一个字符
loop internal
pop cx
mov ax,es
add ax,00ah
mov es,ax
inc bx ;数据段向后推进一个字符来改变颜色信息
loop external
mov ax,4c00h
int 21h
code ends
end start
assume cs:code, ds:data
data segment
str db ‘try‘, 0
data ends
code segment
start:
mov ax, data
mov ds, ax
mov si, offset str
mov al, 2
call printStr
mov ah, 4ch
int 21h
printStr:
push bx
push cx
push si
push di
mov bx, 0b800H
mov es, bx
mov di, 0
s: mov cl, [si]
mov ch, 0
jcxz over
mov ch, al
mov es:[di], cx
inc si
add di, 2
jmp s
over: pop di
pop si
pop cx
pop bx
ret
code ends
end start
assume cs:code, ds:data
data segment
x dw 1984
str db 16 dup(0)
data ends
code segment
start:
mov ax, data
mov ds, ax
mov ax, x
mov di, offset str
call num2str
mov ah, 4ch
int 21h
num2str:
push ax
push bx
push cx
push dx
mov cx, 0
mov bl, 10
s1:
div bl
inc cx
mov dl, ah
push dx
mov ah, 0
cmp al, 0
jne s1
s2:
pop dx
or dl, 30h
mov [di], dl
inc di
loop s2
pop dx
pop cx
pop bx
pop ax
ret
code ends
end start
assume cs:code, ds:data
data segment
x dw 1984
str db 16 dup(0)
data ends
code segment
start:
mov ax, data
mov ds, ax
mov ax, x
mov di, offset str
mov si,0
call num2str
mov ah, 4ch
int 21h
num2str:
push ax
push bx
push cx
push dx
mov cx, 0
mov bl, 10
s1:
div bl
inc cx
mov dl, ah
push dx
mov ah, 0
cmp al, 0
jne s1
s2:
pop dx
or dl, 30h
mov [di], dl
mov dh,2
mov bx,0b800H
mov es,bx
mov es:[si],dx
inc si
inc si
inc di
loop s2
pop dx
pop cx
pop bx
pop ax
ret
code ends
end start
assume cs:code, ds:data
data segment
str db 80 dup(?)
data ends
code segment
start:
mov ax, data
mov ds, ax
mov si, 0
s1:
mov ah, 1
int 21h
mov [si], al
cmp al, ‘#‘
je next
inc si
jmp s1
next:
mov cx, si
mov si, 0
s2: mov ah, 2
mov dl, [si]
int 21h
inc si
loop s2
mov ah, 4ch
int 21h
code ends
end start
文章标题:实验4 汇编应用编程和c语言程序反汇编分析
文章链接:http://soscw.com/index.php/essay/63144.html