BINARY & HEX I/O. Binary input : read in a binary number from keyboard, followed by a carriage return. character strings of 1’s & 0’ we need to convert.

Slides:



Advertisements
Similar presentations
Progam.-(6)* Write a program to Display series of Leaner, Even and odd using by LOOP command and Direct Offset address. Design by : sir Masood.
Advertisements

Program.-(4)* Write a program for input two integer number with message and display their sum. Algorithm steps Algorithm steps 1.Display message for input.
DOS and BIOS Interrupts DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from.
Computer Organization & Assembly Language
Chapter 7 Programming with DOS and BIOS Function Calls Objectives: The use of DOS and BIOS function call How to read the PC’s keyboard How to send text.
Flow Control Instructions
Kip Irvine: Assembly Language for Intel-Based Computers
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
BR 6/001 Ways to Handle I/O (Input/Ouput) For Output –Use Irvine16 Functions Writechar, WriteBin, WriteInt, Writehex, Writestring –Use DOS (Int 21h) Functions.
Program.-(4)* Write a program for input two integer number with message and display their sum. Algorithm steps Algorithm steps 1.Display message for input.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#6)
Lab 5 Part C Write to the screen a character string that uses a ‘$’ to indicate the end of the string. Do not write the ‘$’ to the screen. Use DOS Interrupt.
Topics Control Flow Structure – Conditional Jump – Unconditional Jump Control Flow Structures – IF-THEN – IF-THEN-ELSE – CASE Branches with Compound Conditions.
Lecture 11 Last notes on interrupts and exam review Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
11.1/36 Repeat: From Bits and Pieces Till Strings.
BIOS and DOS Programming in DOS INT 10 and 21H. Interrupts There are some extremely useful subroutines within BIOS or DOS that are available to the user.
1 Screen and Keyboard Operations Suthida Chaichomchuen
Types of Registers (8086 Microprocessor Based)
ICS312 Set 9 Logic & Shift Instructions. Logic & Shift Instructions Logic and Shift Instructions can be used to change the bit values in an operand. The.
Text-Mode Programming Question #1 What are the three levels of access to the video display when writing characters on the screen in text mode?
Lecture 4 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Microprocessors Monday, Apr. 13 Dr. Asmaa Farouk Faculty of Engineering, Electrical Department, Assiut University.
Overview of Assembly Language Chapter 4 S. Dandamudi.
(Flow Control Instructions)
Binary Number Output To display a number in binary format, a program looks at each bit in the number and sends the ASCII equivalent of a ‘1’ (31h) or a.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
21/11/2005CAP2411 Input & Output Instructions CPU communicates with the peripherals through I/O registers called I/O ports. There are 2 instructions, IN.
1 Logic, Shift, and Rotate Instructions Read Sections 6.2, 7.2 and 7.3 of textbook.
10H Interrupt. Option 0H – Sets video mode. Registers used: – AH = 0H – AL = Video Mode. 3H - CGA Color text of 80X25 7H - Monochrome text of 80X25 Ex:
Assembly 05. Outline Bit mapping Boolean logic (review) Bitwise logic Bit masking Bit shifting Lookup table 1.
Control Structure vs. Assembly Language NASM. If-then-else If conditional then then_actions jump to endif else else_actions endif.
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Bitwise and Logical Manipulations Assembly Language Programming University of Akron Dr. Tim Margush.
Boolean, Shift and Rotate instructions Dr.Hadi AL Saadi.
File Operations. FILE PROCESSING For the purposes of the following discussion, reading means copying all or part of an existing file into memory Writing.
Addressing Modes Instruction – Op-code – Operand Addressing mode indicates a way of locating data or operands. – Any instruction may belong to one or more.
1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A.
Microprocessor T. Y. B. Sc..
Instruksi Set Prosesor 8088
Lecture 4 Control Flow Structures (LOOPS)
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Multiplication and Division Instructions
Machine control instruction
Calculator in assembly language
9/17/2018 Kiến Trúc Máy Tính.
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Introduction to Assembly Language
A Hexadecimal Calculator
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
Shift & Rotate Instructions)
Program Logic and Control
Program Logic and Control
Symbolic Instruction and Addressing
Shift & Rotate Instructions)
CS 206D Computer Organization
High-level language structures
UNIT-II Assembly Language Programs Involving Logical
Chapter 6 –Symbolic Instruction and Addressing
Microprocessor and Assembly Language
Multiplication and Division Instructions
Multiplication and Division Instructions
Jump & Loop instructions
Chapter 7 –Program Logic and Control
Chapter 7 –Program Logic and Control
Shift and Rotate Instructions.
Part VI Looping Structures
Presentation transcript:

BINARY & HEX I/O

Binary input : read in a binary number from keyboard, followed by a carriage return. character strings of 1’s & 0’ we need to convert each character to a bit value& collects the bits in a register

Algorithm  Clear BX….. To hold the binary value  Input a character …….. ‘1’ or ‘0’  WHILE character <> CR then Convert character to binary value Left shift BX Insert value into LSB of BX Input a character END_WHILE

The algorithm assumes  Input characters are either “0”,”1”or CR  At most 16 bit are input  BX is shifted left to make room and the OR operation is used to insert the new bit into BX

Code XORBX,BX; clear BX MOVAH,1 ; input character function INT21H; read a character WHILE_: CMPAL,0DH ; CR ? JEEND_WHILE ; yes, done ANDAL,0FH ; no, convert to binary value SHLBX,1; make room for new value ORBL,AL; put value in BX INT21H ; read a character JMPWHILE_; loop back END_WHILE :

Binary output: Outputting contents of BX in binary … Shift Operation

Algorithm FOR 16 times DO Rotate left BX /* BX … output CF … MSB */ IF CF = 1 THEN output ‘1’ ELSE output ‘0’ END_IF END_FOR

Binary output MOV AH, 2 MOV CX, 16 TOP: ROL BL,1 JC ONE JNC ZERO ONE: MOV DL,'1‘ ; or ( 31h) JMP DISPLAY ZERO: MOV DL,'0‘ ; or (30h ) DISPLAY: INT 21H LOOP TOP

Hex Input Digits “0” to “9” & letters “A” to “F” Followed by a carriage return

Assume  Only upper case letters are used.  The user inputs no more than 4 hex characters.  BX must be shifted 4 times to make room for a hex value.

Algorithm for hex input  Clear BX  Input a hex character  WHILE character <> CR DO  Convert character to binary value  Left shift BX 4 times  Insert value into lower 4 bits of BX  Input a character END_WHILE

Code XORBX,BX ; clear BX MOV CL,4 MOVAH,1 ; input character function INT21H ; read a character WHILE_: CMPAL,0DH; CR ? JEEND_WHILE; yes, done ; convert character to binary digit CMPAL,39H ; a digit ? JGLETTER ; no, a letter ; input is a digit ANDAL,0FH ; convert digit to binary value JMPSHIFT ; go to insert in BX

Code LETTER: SUBAL, 37H ; convert letter to binary value SHIFT: SHLBX,CL ;make room for new value ; insert value into BX ORBL,AL ; put value into low 4 bits of BX INT21H ; input a character JMPWHILE_ ; loop until CR END_WHILE: