史萊姆論壇

返回   史萊姆論壇 > 專業主討論區 > 程式語言討論區
忘記密碼?
論壇說明

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


 
 
主題工具 顯示模式
舊 2006-12-07, 02:09 AM   #1
kinco
註冊會員
榮譽勳章
UID - 248756
在線等級: 級別:8 | 在線時長:113小時 | 升級還需:4小時級別:8 | 在線時長:113小時 | 升級還需:4小時級別:8 | 在線時長:113小時 | 升級還需:4小時
註冊日期: 2003-02-06
VIP期限: 2007-04
住址: 台北.中和
文章: 507
精華: 0
現金: 0 金幣
資產: 670 金幣
預設 程式 - 組合語言的問題~如何防呆

想要做出只能輸入數字~不能輸入字母的防呆~但是我完全把語法忘了~請會的大哥大姊~幫幫小弟吧~萬分感激

引用:
;Add individual digits of a number ADDIGITS.ASM
;
; Objective: To find the sum of individual digits of
; a given number. Shows character to binary
; conversion of digits.
; Input: Requests a number from keyboard.
; Output: Prints the sum of the individual digits.
.MODEL SMALL
.STACK 100H
.DATA
number_prompt db "Please type a number (<11 digits): ",0
out_msg db "The sum of individual digits is: ",0
number db 11 DUP (?)

.486
.CODE
INCLUDE io.mac
.STARTUP
PutStr number_prompt ; request an input number
GetStr number,11 ; read input number as a string
nwln
mov EBX,OFFSET number ; EBX = address of number
sub DX,DX ; DX = 0 -- DL keeps the sum
repeat_add:
mov AL,[EBX] ; move the digit to AL
cmp AL,0 ; if it is the NULL character
je done ; sum is done
and AL,0FH ; mask off the upper 4 bits
add DL,AL ; add the digit to sum
inc EBX ; update EBX to point to next digit
jmp repeat_add
done:
PutStr out_msg
PutInt DX ; write sum
nwln
.EXIT
END
kinco 目前離線  
送花文章: 23, 收花文章: 5 篇, 收花: 9 次
回覆時引用此帖
 



發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用


所有時間均為台北時間。現在的時間是 02:01 PM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2025, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1