6.asm

来自「分类统计字符个数count_char 要求程序接受用户输入一行字符(字符个数」· 汇编 代码 · 共 84 行

ASM
84 行
字号
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitcode:DWORD
INCLUDE io.h

cr          EQU    0dh   ; 
Lf          EQU    0ah   ; 

.STACK  4096             ; 
.DATA
prompt      BYTE   cr,Lf,Lf,"please input string:",0
stringIN    BYTE   80 DUP(?)
prompt1     BYTE   cr,Lf,Lf,"number of digital:",0
prompt2     BYTE   cr,Lf,Lf,"number of word:",0
prompt3     BYTE   cr,Lf,Lf,"number of other:",0
prompt4     BYTE   cr,lf,"Try again? (y) ",0
count1      DWORD  ?
count2      DWORD  ?
count3      DWORD  ?
string2      BYTE   16 DUP  (?)
value       BYTE   16 DUP  (?)


.CODE
_start:
forcount0:  output   prompt
            input    stringIN,80
            lea      ebx     ,stringIN
            mov      count1,0
            mov      count2,0
            mov      count3,0    
                 
forcount1:  cmp      byte ptr [ebx],00H
            je       forcount5
            cmp      byte ptr [ebx],'0'
            jb       forcount4
            cmp      byte ptr [ebx],'9'
            ja       forcount2
            inc      count1
            add      ebx,1
            jmp      forcount1
   

forcount2:  cmp      byte ptr [ebx],'A'
            jb       forcount4
            cmp      byte ptr [ebx],'Z'
            ja       forcount3
            add      ebx,1
            inc      count2
            jmp      forcount1      
    

forcount3:  cmp      byte ptr [ebx],'a'
            jb       forcount4
            cmp      byte ptr [ebx],'z'
            ja       forcount4
            add      ebx,1
            inc      count2
            jmp      forcount1
    

forcount4:  inc      count3
            add      ebx,1 
            jmp      forcount1 

forcount5:  output   prompt1
            dtoa     string2,count1
            output   string2
            output   prompt2
            dtoa     string2,count2
            output   string2
            output   prompt3
            dtoa     string2,count3
            output   string2
            output   prompt4
            input    value,16
            cmp      value,'y'
            je       forcount0

            INVOKE   ExitProcess,0                       
PUBLIC _start 
            END
              

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?