CS 206D Computer Organization
This presentation is the property of its rightful owner.
Sponsored Links
1 / 4

CS 206D Computer Organization Lab7 PowerPoint PPT Presentation


  • 63 Views
  • Uploaded on
  • Presentation posted in: General

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

Download Presentation

CS 206D Computer Organization Lab7

An Image/Link below is provided (as is) to download presentation

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


Cs 206d computer organization lab7

CS 206D Computer Organization

Lab7

CS 111


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

MOV AX, @DATA ; initialize DS

MOV DS, AX

MOV CX , 4

XOR BX,BX ;Clear bx


Cs 206d computer organization lab7

READ: ;Loop label to read 4 numbers in binary form

;print PROMPT_1 the message

LEA DX, PROMPT_1

MOV AH, 9

INT 21H

MOV AH,1 ;read char

INT 21H

WHILE_:

CMP AL, 0DH ; CR?

JE ReadNext;Yes, done

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

SHL BX , 1 ;make room for the new bit

OR BL,AL ;put value into BX

INT 21H ; read again

JMP WHILE_

ReadNext:

ADD TOTAL,BX

XOR BX,BX ;Clear bx

LOOP READ


Cs 206d computer organization lab7

;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


  • Login