assembly x86(nasm)的日常

cs的日常打卡。

 

 

data    segment
ENG         db    'SUNdayS Coming I Wanna Drive My Car,SUN,SUN$'        ;43,35
sun1        db    'SUN'
swcount        db    0ah,0dh,'single word number:',?,?,'$'
suncount    db    0ah,0dh,'SUN:',?,'$'
data    ends
code    segment
assume    cs:code,ds:data,es:data
start:
            mov    ax,data
            mov    ds,ax    
            mov    es,ax        
            lea dx,ENG        
            mov    ah,9                        
            int    21h
swcount1:                                        
            mov al,ENG[si]
            cmp al,'$'
            jz     output1
            cmp al,'A'
            jb     next
            cmp al,'Z'
            ja     text1
            jmp addswc
text1:        cmp al,'a'
            jb     next
            cmp al,'z'
            ja     next
addswc:        inc swcount[21]
            cmp al,'S'
            jz  strcmp
            jmp next
to:
            pop si
next:        inc si
            jmp swcount1
strcmp:
            push si
            cld
            xor di,di
            lea di,sun1
            lea si,ENG[si]
            mov cx,3
            repz cmpsb
            jnz addcount
            inc suncount[6]
addcount:    
            jmp to

output1:
            xor cx,cx    
            mov al,swcount[21]
            cbw
loopb:
            xor dx,dx
            inc cl
            mov bx,10
            div bx                    ;ax商,dx余
            push dx                    ;余数入栈
            cmp ax,0
            jne loopb
            xor si,si
loopc: 
            pop dx
            or  dl,00110000b
            mov swcount[21+si],dl
            inc si
            loop loopc

            lea dx,swcount    
            mov    ah,9                        
            int    21h                
            or suncount[6],00110000b
            lea dx,suncount
            mov    ah,9                        
            int    21h            
exit:        mov    ah,4ch                        
            int    21h
code    ends
end    start

 

posted @ 2019-06-05 21:01  Lancelot&  阅读(314)  评论(0编辑  收藏  举报