1 / 4

# CS 206D Computer Organization Lab7 - PowerPoint PPT Presentation

CS 206D Computer Organization Lab7. MODEL SMALL . STACK 100H . DATA PROMPT_1 DB 0DH,0AH,'Enter a number in binary form ( max 4-bit )\$' PROMPT_2 DB 0DH,0AH,'The Average of the 4 numbers in Hexadecimal form is : \$' Total DW ? . CODE MAIN PROC

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' CS 206D Computer Organization Lab7' - shelagh-kennefick

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Lab7

CS 111

.STACK 100H

.DATA

PROMPT_1 DB 0DH,0AH,'Enter a number in binary form ( max 4-bit )\$'

PROMPT_2 DB 0DH,0AH,'The Average of the 4 numbers in Hexadecimal form is : \$'

Total DW ?

.CODE

MAIN PROC

MOV AX, @DATA ; initialize DS

MOV DS, AX

MOV CX , 4

XOR BX,BX ;Clear bx

;print PROMPT_1 the message

LEA DX, PROMPT_1

MOV AH, 9

INT 21H

INT 21H

WHILE_:

CMP AL, 0DH ; CR?

AND AL,0FH ; no , convert char to binary

SHL BX , 1 ;make room for the new bit

OR BL,AL ;put value into BX

JMP WHILE_

XOR BX,BX ;Clear bx

;calculate avarge

MOV cl , 4

MOV ax,TOTAL

DIV CL

MOV BL , AL

PRTINT_HEX:

LEA DX, PROMPT_2 ; load and display the string PROMPT_2

MOV AH, 9

INT 21H

MOV CX, 4 ; initialize loop counter

MOV AH, 2 ; set output function

Display: ;loop lable

MOV DL, BH

SHR DL,4

CMP DL , 9 ; DL <=9?

JBE DIGIT ;yes, it is digit

ADD DL, 37H ; no, it is letter

JMP print_char

DIGIT:

OR DL, 30H

print_char:

INT 21H

ROL BX,4

LOOP Display