Programming

Just another WordPress.com weblog

ข้อสอบ CT215 ปี 2551 เขียน code assembly ยาว

แสดงความเห็นโดย จั่น บน ธันวาคม 8, 2008

โจทย์ ป้อนข้อมูลเป็นฐาน 16 แล้วให้พิมพ์ออกมาในรูป Binary และฐาน 10 (ฺBinary ขอแสดงเพียง 8 หลักต่ำเท่านั้น ห้ามแสดง 32 หลักจาก eax)

Hex to Bin and Decimal
Hex: 56
Binary: 01010110
Decimal: +86
Continue (y/n):

————

TITLE (HexToBinAndDecimal.asm)

; This program
; Last update:

Include Irvine32.inc
Include Macros.inc
.data
.code
main PROC

Start:

call Clrscr

mWrite <”Hex to Bin and Decimal”,0dh,0ah>

mWrite “Hex: “

call ReadHex

mWrite “Binary: “

mov ebx, eax

;BLOCK PRINT 8 BIT BINARY
SHL eax,24
mov ecx,8

L1:

SHL eax,1
jnc WRITEZERO

mWrite “1″
jmp L2

WRITEZERO:

mWrite “0″

L2: LOOP L1

mov eax, ebx

call Crlf

mWrite “Decimal: “

call WriteInt

call Crlf

mWrite “Continue (y/n): “
call ReadChar
call WriteChar

cmp al,79H
je Start

exit
main ENDP
END main

ใส่ความเห็น

XHTML: คุณสามารถใช้แท็กเหล่านี้ได้: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>