;分類統計字串中大小寫字母,數字,其他字元個數;定義字串,不需要鍵盤輸入,統計結果依次儲存到X1,X2,X3,X4中data segmentbuf db "asdg123456,^&%$#$"X1 db 0X2 db 0X3 db 0X4 db 0 data endscode segmentassume cs:code, ds:datastart:mov ax,datamov ds,axlea bx,buf ;定位首個字元mov cx,X1-buf ;計算字元個數lop:mov al,[bx]cmp al,"a"jb next1cmp al,"z"ja next1inc X1 ;小於a大於z則跳到下一項,否則X1+1jmp exitnext1:cmp al,"A"jb next2cmp al,"Z"ja next2inc X2 ;小於A大於Z則跳到下一項,否則X2+1jmp exitnext2:cmp al,"0"jb next3cmp al,"9"ja next3inc X3 ;小於0大於9則跳到下一項,否則X3+1jmp exitnext3:inc X4 ;剩下就是其它字元了,X4+1exit:inc bxloop lop ;迴圈mov ax,4c00hint 21hcode endsend start
;分類統計字串中大小寫字母,數字,其他字元個數;定義字串,不需要鍵盤輸入,統計結果依次儲存到X1,X2,X3,X4中data segmentbuf db "asdg123456,^&%$#$"X1 db 0X2 db 0X3 db 0X4 db 0 data endscode segmentassume cs:code, ds:datastart:mov ax,datamov ds,axlea bx,buf ;定位首個字元mov cx,X1-buf ;計算字元個數lop:mov al,[bx]cmp al,"a"jb next1cmp al,"z"ja next1inc X1 ;小於a大於z則跳到下一項,否則X1+1jmp exitnext1:cmp al,"A"jb next2cmp al,"Z"ja next2inc X2 ;小於A大於Z則跳到下一項,否則X2+1jmp exitnext2:cmp al,"0"jb next3cmp al,"9"ja next3inc X3 ;小於0大於9則跳到下一項,否則X3+1jmp exitnext3:inc X4 ;剩下就是其它字元了,X4+1exit:inc bxloop lop ;迴圈mov ax,4c00hint 21hcode endsend start