1 Star 0 Fork 1

fengxueygr/intel_asm

forked from 西边/intel_asm 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
a3.asm 2.85 KB
一键复制 编辑 原始数据 按行查看 历史
西边 提交于 2021-10-03 17:22 . commit
; 003.c
global _main
section .data
LC0:
db "please input a number string:",0Ah,0
LC1:
db "please input n(2 or 8 or 16):",0Ah,0
LC2:
db "%d",0
LC3:
db "data error!!",0
LC4:
db "the decimal is %ld",0Ah,0
extern _memset,_gets,_strupr,_printf,_strlen,_scanf,_exit
section .text
_main:
push ebp
mov ebp,esp
sub esp,0x1000
mov dword [ebp-0x1000],0 ; t1
mov dword [ebp-0xffc],0 ; i
mov dword [ebp-0xff8],0 ; n
mov dword [ebp-0xff4],0 ; t
mov dword [ebp-0xff0],0 ; t3
mov dword [ebp-0xfe0],0 ; a
mov dword [esp+8],100
mov dword [esp+4],0
lea eax,[ebp-0xfe0] ; a
mov [esp+0],eax
call _memset
sub esp,12
mov dword [esp+0],LC0
mov eax,0
call _printf
sub esp,4
lea eax,[ebp-0xfe0] ;a
mov [esp+0],eax
call _gets
sub esp,4
lea eax,[ebp-0xfe0] ;a
mov [esp+0],eax
call _strupr
sub esp,4
lea eax,[ebp-0xfe0] ;a
mov [esp+0],eax
call _strlen
sub esp,4
mov [ebp-0xff0],eax ; t3
mov dword [ebp-0x1000],0 ; t1
mov dword [esp+0],LC1
mov eax,0
call _printf
sub esp,4
lea eax,[ebp-0xff8] ; n
mov [esp+4],eax
mov dword [esp+0],LC2
mov eax,0
call _scanf
sub esp,8
mov dword [ebp-0xffc],0 ; i
jmp .Lmain_400
.Lmain_500:
mov eax,[ebp-0xffc] ; i
lea edi,[ebp-0xfe0] ; a
mov cl,[edi+eax] ; a[i]
sub cl,48 ; '0'
movsx ecx,cl
cmp ecx,[ebp-0xff8] ;n
jl .Lmain_490
mov eax,[ebp-0xffc] ;i
lea edi,[ebp-0xfe0] ;a
cmp byte [edi+eax],65 ; 'A'
jge .Lmain_490
jmp .Lmain_489
.Lmain_490:
mov eax,[ebp-0xffc] ; i
lea edi,[ebp-0xfe0] ;a
mov cl,[edi+eax] ; a[i]
sub cl,65 ; 'A'
add cl,10
movsx ecx,cl
cmp ecx,[ebp-0xff8] ; n
jl .Lmain_480
.Lmain_489:
mov dword [esp+0],LC3
mov eax,0
call _printf
sub esp,4
mov dword [esp+0],0
call _exit
sub esp,4
.Lmain_480:
mov eax,[ebp-0xffc] ;i
lea edi,[ebp-0xfe0] ;a
cmp byte [edi+eax],48 ;'0'
jl .Lmain_470
mov eax,[ebp-0xffc] ;i
lea edi,[ebp-0xfe0] ;a
cmp byte [edi+eax],57 ;'9'
jg .Lmain_470
mov eax,[ebp-0xffc] ;i
lea edi,[ebp-0xfe0] ;a
mov cl,[edi+eax] ; a[i]
sub cl,48 ; '0'
movsx ecx,cl
mov [ebp-0xff4],ecx ; t
jmp .Lmain_460
.Lmain_470:
cmp dword [ebp-0xff8],11 ; n
jl .Lmain_460
mov eax,[ebp-0xffc] ; i
lea edi,[ebp-0xfe0] ; a
cmp byte [edi+eax],65 ; 'A'
jl .Lmain_460
mov al,65 ; 'A'
add al,[ebp-0xff8] ; n
sub al,10
mov cl,al
mov eax,[ebp-0xffc] ;i
lea edi,[ebp-0xfe0] ;a
cmp cl,[edi+eax]
jl .Lmain_460
mov eax,[ebp-0xffc] ;i
lea edi,[ebp-0xfe0] ;a
mov al,[edi+eax] ; a[i]
sub al,65 ;'A'
add al,10
mov [ebp-0xff4],al ; t
.Lmain_460:
mov eax,[ebp-0x1000] ; t1
imul eax, [ebp-0xff8] ; n
add eax,[ebp-0xff4] ; t
mov [ebp-0x1000],eax ; t1
add dword [ebp-0xffc],1 ;i
.Lmain_400:
mov eax,[ebp-0xffc] ; i
cmp [ebp-0xff0],eax ; t3
jg .Lmain_500
mov eax,[ebp-0x1000] ; t1
mov [esp+4],eax
mov dword [esp+0],LC4
mov eax,0
call _printf
sub esp,8
mov eax,0
leave
ret
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fengxueygr/intel_asm.git
git@gitee.com:fengxueygr/intel_asm.git
fengxueygr
intel_asm
intel_asm
master

搜索帮助