汇编-统计字符串中大写字母的个数(小于10个)

data segment
  String  db 'Hello The World!'
  String2 db '$'
  x1      db  0
  x2      db  0
  x3      db  0
  x4      db  0
data ends

code segment
assume cs:code,ds:data
start:
  mov ax,data
  mov ds,ax

  lea bx,String
  mov cx,x1-String
judge:
  mov al,[bx]
  cmp al,'a'
  jb next1
  cmp al,'z'
  ja next1
  inc x1
  jmp exit
next1:
  cmp al,'A'
  jb next2
  cmp al,'Z'
  ja next2
  inc x2
  jmp exit
next2:
  cmp al,'0'
  jb next3
  cmp al,'9'
  ja next3
  inc x3
  jmp exit
next3:
  inc x4
exit:
  inc bx
  loop judge

  mov dl,[bx+1]
  add dl,30h
  mov ah,02h
  int 21h

  mov ax,4c00h
  int 21h

code ends
  end start

你可能感兴趣的:(#,汇编语言)