從鍵盤輸入一個十進制個位數,在屏幕上顯示相應數量的該數。 例如,輸入3,屏幕上將顯示“333”。

問題

從鍵盤輸入一個十進制個位數,在屏幕上顯示相應數量的該數。
例如,輸入3,屏幕上將顯示“333”。

代碼

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

運行結果

在這裏插入圖片描述
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章