Enter a decimal single digit from the keyboard and display the corresponding number of this number on the screen. For example, enter 3 and "333" will be displayed on the screen.

problem

Enter a decimal single digit from the keyboard and display the corresponding number of that number on the screen.
For example, enter 3 and "333" will be displayed on the screen.

Code

data segment
  hitinput db 'please input a number:$';输入提示语句
  hitoutput db 'it is ouput:$';输出提示语句
  crlf db 0ah,0dh,'$';回车换行
data ends
code segment
assume cs:code,ds:data
main proc far
start:
  mov ax,data
  mov ds,ax
  lea dx,hitinput;输入十进制数的提示语
  mov ah,09h
  int 21h
  lea dx,crlf;回车换行
  mov ah,09h
  int 21h
  mov ah,01h  ;把a保存在cl中
  int 21h
  sub al,30h;先减去30h,保存dl的十进制数
  mov cl,al
  lea dx,crlf;回车换行
  mov ah,09h
  int 21h
  
  lea dx,hitoutput;输出和的提示语
  mov ah,09h
  int 21h
  lea dx,crlf;回车换行
  mov ah,09h
  int 21h
  mov ch,0
  mov dl,cl
  add dl,30h;加上30h,输出ascill值
L1:             ;循环输出dl
  mov ah,02h
  int 21h
  loop L1
  mov ax,4c00h
  int 21h
main endp
code ends
end start

operation result

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43475285/article/details/106295693