Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Assignment 3 – Writing a procedure program HexOutput, HexInput

Click Here to enroll in this course now


Assembly language x86 processors for beginners

60-266 – Assignment #3

1. Write a procedure called HexOutput that displays the content of register EBX in hexadecimal string. A full solution for the binary case (BinOutput) .
For example: If EBX contains 1111 1110 0000 0001 1100 1000 0011 0111, then the procedure HexOutput should display the hexadecimal string “FE01C837h”.

2. Write a procedure called HexInput that loads the register EAX with the numerical value of the hexadecimal string entered at the keyboard. A full solution for the binary case (BinInput).
For example: EAX is loaded with 1111 1110 0000 0001 1100 1000 0011 0111, when the procedure HexInput reads the hexadecimal string “FE01C837h”.

3.  To test these two procedures, above, your main program should first ask you “What do you want to do?”.
a. If you type the letter W (or w) then the main program reads an unsigned 32-bit decimal number from the keyboard, and loads the number into EBX, and then calls the procedure HexOutput (which displays an hexadecimal string).
b. If you type the letter R (or r) then the main program calls the procedure HexInput (which reads a string from the keyboard and loads it into EAX), and then displays the binary content of register EAX.
c. It exits with “Get Lost Sweetey Honey” if you type anything else. . In a and b, above, the main program exits with “Thank you Sweetey Honey”

Answer(partial):

INCLUDE Irvine32.inc

.data
	str1 BYTE "What do you want to do? ", 0
	str2 BYTE "Get Lost Sweety Honey ", 0ah, 0dh, 0
	str3 BYTE "Thank you Sweety Honey ", 0ah, 0dh, 0

.code
  main PROC
	call Clrscr
	mov  edx, OFFSET str1
	call WriteString

  check1 :

  check2 :
	call HexInput
  quitmain :
exit
main ENDP

HexOutput PROC
	MOV ECX, 0
  again :
	CMP ECX, 8; make sure we loop throught all 8 bytes(32bits)
	JAE exit1
	ROL EBX, 4
	MOV DL, BL
	AND DL, 0fh; convert to binary value
	shl ebx, 4; make room for new value
	or bl, DL; put value in ls bit
	inc ecx
	LOOP again
  exit1 :
	call Clrscr

	call Crlf
	RET
HexOutput ENDP

HexInput PROC
	xor ebx, ebx
  next :
	call Readchar
	cmp al, 0Dh; exit if input is "enter"
	je  exit2

  next1 :


  next1a:

  next2 :


  next2a :
	cmp al, 64h;check small letter d

  next3 :
	cmp al, 44h;check capital D


  next3a :

	mov al, 0ch
  next4 :

	mov al, 0ch

  next4a :
	cmp al, 62h;check small letter b

  next5 :
	cmp al, 42h;check capital B


  next5a :

	mov al, 0ah
  next6 :


  next6a :
	and al, 0Fh

	jmp next
  exit2 :
	mov eax, ebx
	call Clrscr

	RET
HexInput ENDP

  quit :
	call Clrscr
	mov  edx, OFFSET str2
	call WriteString
exit
END main

Click Here to enroll in this course now


Assembly language x86 processors for beginners

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!