ข้อสอบ CT215 คูณเลขแบบมีเครื่องหมาย
แสดงความเห็นโดย จั่น บน ธันวาคม 10, 2008
โจทย์ ให้ตัวตั้งอย่างมากใส่ได้เป็นตัวเลข 3 หลัก และตัวนำมาคูณก็ 3 หลักเช่นกัน เขียน program คูณกันธรรมดาแบบมีเครื่องหมาย
Program Multiply Two Integers
MULTIPLICAND : 5
MULTIPLIER : -5
PRODUCT : -25
RUN AGAIN (y/n):
———–
TITLE (Multipli.asm)
Include Irvine32.inc
Include Macros.inc
.data
.code
main PROC
Start:
call Clrscr
mGotoxy 20,10
mWrite <”Program Multiply Two Integers”,0dh,0ah>
mGotoxy 20,11
mWrite “MULTIPLICAND : “
call ReadInt
mov ebx, eax
mGotoxy 20,12
mWrite “MULTIPLIER : “
call ReadInt
IMUL ebx
mGotoxy 20,13
mWrite “PRODUCT : “
call WriteInt
mGotoxy 20,14
mWrite “RUN AGAIN (y/n): “
call ReadChar
cmp al, ‘y’
je Start
exit
main ENDP
END main

Spore กล่าว
++++มันน่าจะเป็นงี้เปล่าอ่ะ++++
ลองดูหลายๆ แบบ
ลองเชื่อในความเห็นที่แตกต่างดูเด้อ
+++Spore+++
TITLE (Multipli.asm)
Include Irvine32.inc
.stack 64
.data
txt1 byte “MULTIPLICAND : “,0
txt2 byte “Program Multiply Two Integers”,0
txt3 byte “MULTIPLIER : “,0
txt4 byte “PRODUCT :”,0
txt5 byte “RUN AGAIN (y/n):”,0
.code
PRINT MACRO TXT
LEA EDX,TXT
CALL WriteString
ENDM
SETCUR MACRO ROW,COL
MOV DH,ROW
MOV DL,COL
CALL gotoXY
ENDM
main PROC
Start: call Clrscr
SETCUR 10,20
PRINT txt2
CALL CRLF
SETCUR 11,20
PRINT txt1
CALL ReadInt
mov ebx, eax
SETCUR 12,20
PRINT txt3
CALL ReadInt
IMUL ebx
SETCUR 13,20
PRINT txt4
call WriteInt
SETCUR 15,20
PRINT TXT5
call ReadChar
cmp al,’y’
je Start
exit
main ENDP
END main
จั่น กล่าว
ผมขอดูตรงส่วนสำคัญนะครับ
call ReadInt
mov ebx, eax
call ReadInt
IMUL ebx
call WriteInt
ซึ่งเหมือนกันเลยครับ ส่วนตกแต่งใครจะทำอย่างไรก็ได้ ผมว่านะ
Spore กล่าว
เออ มันก็จริงแฮะ
Spore กล่าว
สอบวันที่ 07/03/52 เน้อ ง่ายเน้อ รีบเก็บกันเน้อพี่น้องงงงงงงง…..