Principles of Computer Organization Assembly Language

1. Add from 1 to 100

   ;从一加到一百
   	mov ax,0
   	mov bx,0
   	a2:add ax,bx
   	inc bx 
   	cmp bx,100
   	jle a2

2. Add 1 to 100 to output hexadecimal

    ;输出从一加到一百的结果以十六进制输出
    mov ch,4
    mov ax,0
    mov bx,1
 a2:add ax,bx
    inc bx
    cmp bx,100
    jle a2
    mov bx,ax 
    mov cl,4
 a3:rol bx,cl
    mov al,bl
    and al,0fh
    add al,30h
   cmp al,39h
   jle a4
   add al,7
  a4:mov dl,al
    mov ah,2
    int 21h
    dec ch
    cmp ch,1
    jge a3

3. Output 26 uppercase letters

    ;输出26个大写字母
    mov ch,1
    mov bl,'A'
    a2:mov dl,bl
    mov ah,2
    int 21h
    inc bl
    inc ch
    cmp ch,26
    jle a2

4. Output 52 uppercase and lowercase letters (only one cycle is used)

   ;输出52个大小写小字母(只用一个循环)
   mov ch,1
   mov bl,'A'
   a2:mov dl,bl
   mov ah,2
   int 21h
   mov cl,bl
   add cl,20h
   mov dl,cl
   mov ah,2
   int 21h
   inc bl
   inc ch
   cmp ch,26
   jle a2

5. Input a character from the keyboard and output the corresponding ASCII code

   mov ch,8
    mov ah,1
    int 21h
    mov bl,al
    a4:test bl,80h
    jz a2
    mov dl,'1'
    mov ah,2
    int 21h
    jmp a3
    a2:mov dl,'0'
    mov ah,2
    int 21h
    a3:rol bl,1
    dec ch
    cmp ch,1
    jge a4

6. Output the input characters without echo

 ;将输入的无回显的字符输出
   mov dx,offset str1
   mov ah,9
   int 21h
  a5:mov bx,offset str2
  a4:mov ah,7
  int 21h
  cmp al,0dh
  jz a2
  mov dh,al
  mov ah,2
  mov dl,'*'
  int 21h
  mov [bx],dh
  inc bx
  jmp a4
  a2:mov byte ptr [bx],'$'
  mov dx,offset str2
    mov ah,9
    int 21h

7. Output the data segment code in ASCII form

 ;将数据段代码以ASCII形式输出
    mov dh,11
    mov si,offset st1
    a6:mov bl,[si]
    mov ch,2
    mov cl,4
    a3:rol bl,cl
    mov al,bl
    and al,0fh
    add al,30h
    cmp al,39h
    jle a4
    add al,7
    a4:mov dl,al
    mov ah,2
    int 21h
    dec ch
    cmp ch,1
    jge a3
    inc si
    mov ah,2
    mov dl,20h
    int 21h
    dec dh
    cmp dh,1
    jge a6

Guess you like

Origin blog.csdn.net/m0_52900946/article/details/125452279