1 / 4

CS 206D Computer Organization Lab7

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

Télécharger la présentation

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 206D Computer Organization Lab7 CS 111

  2. 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

  3. 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

  4. ;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

More Related