[問題] 關於除法指令div的問題
關於除法指令div的問題
程式目的:將一數除以另一數後將商及餘數轉成ASCII的數字後輸出,
發生一些問題:
1.除數若在13以下顯示的結果就會變成divide overflow,但若超過就沒有此問題.
2.轉成ASCII後完全不是該數字,如20/14後,應是1餘6,但轉成ASCII輸出後,會變成2b,
30/14後,應是2餘2,但轉成ASCII輸出後,會變成字元 < l (L的小寫),整個都亂掉
3.若不呼叫 tochar, 則31/14沒有輸出任何字元.31/17輸出3行空白, 35/20輸出兩顆心號
(ASCII數值為3)
似乎找不到任何規則可debug?
我在懷疑是否有暫存器的數值沒清乾淨歸零,但我用的指令是mov不是add阿?
或者沒有初始化暫存器為0?但好像也沒效果...
麻煩幫我看看哪裡錯了,感謝!感謝!
程式碼:
mov dl,20
mov ax,dx
mov cl,14
div cl
mov dl,ah ;6
call tochar
call show
mov dl,al ;1
call tochar
call show
exit: mov ah,4ch
int 21h
;--------------------------
tochar proc near
mov bl,48
add dl,bl
ret
tochar endp
show proc near
mov ah,2
int 21h
ret
show endp
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.38.9.137
※ 編輯: ppttcc 來自: 114.38.9.137 (11/04 15:22)
推
11/04 16:14, , 1F
11/04 16:14, 1F
推
11/04 20:44, , 2F
11/04 20:44, 2F
→
11/04 20:46, , 3F
11/04 20:46, 3F
推
11/04 20:59, , 4F
11/04 20:59, 4F
推
11/04 21:17, , 5F
11/04 21:17, 5F
→
11/04 21:56, , 6F
11/04 21:56, 6F
推
11/04 21:58, , 7F
11/04 21:58, 7F
→
11/04 21:58, , 8F
11/04 21:58, 8F
→
11/04 22:09, , 9F
11/04 22:09, 9F
→
11/04 22:10, , 10F
11/04 22:10, 10F
推
11/04 22:13, , 11F
11/04 22:13, 11F
→
11/04 23:22, , 12F
11/04 23:22, 12F
→
11/04 23:23, , 13F
11/04 23:23, 13F
→
11/04 23:25, , 14F
11/04 23:25, 14F
推
11/04 23:30, , 15F
11/04 23:30, 15F
→
11/04 23:33, , 16F
11/04 23:33, 16F
→
11/04 23:34, , 17F
11/04 23:34, 17F
推
11/04 23:35, , 18F
11/04 23:35, 18F
推
11/04 23:36, , 19F
11/04 23:36, 19F
→
11/04 23:37, , 20F
11/04 23:37, 20F
→
11/04 23:37, , 21F
11/04 23:37, 21F
推
11/04 23:41, , 22F
11/04 23:41, 22F
→
11/04 23:54, , 23F
11/04 23:54, 23F
推
11/04 23:56, , 24F
11/04 23:56, 24F
→
11/05 00:07, , 25F
11/05 00:07, 25F
→
11/05 00:30, , 26F
11/05 00:30, 26F
討論串 (同標題文章)
ASM 近期熱門文章
PTT數位生活區 即時熱門文章