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.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
Introduction to Computer Engineering by Richard E. Haskell BCD Arithmetic Module M16.5 Section 10.4.
Introduction to Computer Engineering by Richard E. Haskell Multiplication and Division Instructions Module M16.4 Section 10.4.
Department of Computer Science and Software Engineering
Computer Organization & Assembly Language
More about procedures and Video Processing. Lesson plan Review existing concepts More about procedures and boolean expression Video processing.
Important Irvine Library Procedures Randomize Randomize –Initializes the seed of the random-number formula by both the Random32 and the RandomRange procedures.
Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, All rights reserved. You may modify and.
Runtime Stack Managed by the CPU, using two registers
Kip Irvine: Assembly Language for Intel-Based Computers Overview Stack Operations (PUSH and POP) Procedures Procedure Parameters Software Interrupts MS-DOS.
Kip Irvine: Assembly Language for Intel-Based Computers
CS2422 Assembly Language & System Programming October 24, 2006.
8.4 Instruction Execution Times TOBIN PROC FAR SUB AX,AX MOV DX,AX MOV CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
They are the same as registers since they store binary numbers. Called shifting registers since they shift (left or right) the binary number stored in.
Digital Logic Chapter 2 Number Conversions Digital Systems by Tocci.
Assembly Language – Lab 5
Simple Data Type Representation and conversion of numbers
ICS312 Set 4 Program Structure. Outline for a SMALL Model Program Note the quiz at the next lecture will be to reproduce this slide.MODEL SMALL.586 ;
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.
Lecture 11 Last notes on interrupts and exam review Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer.
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.
Programming the Microprocessor A Course in Microprocessor Electrical Engineering Dept. University of Indonesia.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
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
ASCII and BCD Arithmetic Chapter 11 S. Dandamudi.
Functions available for Writing to the Video Display Three different ways to write to the display –Irvine library functions –DOS Video Functions (Interrupt.
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.
Multiplication and Division Instructions & the 0Ah function.
Microprocessors Monday, Apr. 13 Dr. Asmaa Farouk Faculty of Engineering, Electrical Department, Assiut University.
Arithmetic Flags and 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.
ASSEMBLY LANGUAGE FOR INTEL-BASED COMPUTERS, PROCEDURES.
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.
Software Interrupt Instruction ‘int’ A ‘int’ instruction is like a special kind of subroutine call. Will discuss details later ‘int’ stands for INTERRUPT.
Assembly Language for Intel-Based Computers, 4 th Edition Unpacked and Packed Integers (c) Pearson Education, All rights reserved. You may modify.
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:
Lecture 9 (The Stack and Procedures). 1 Lecture Outline Introduction The Stack The PUSH Instruction The POP Instruction Terminology of Procedures INDEC.
LEA instruction The LEA instruction can be used to get the offset address of a variable Example ORG 100h MOV AL, VAR1 ; check value of VAR1 by moving it.
Irvine, Kip R. Assembly Language for Intel-Based Computers. Chapter 7: Integer Arithmetic Slides to Accompany Assembly Language for Intel-Based Computers,
ICS 312 SET 10 Multiplication & Division & input using function 0Ah.
What is an Operating System ? ReadString() WriteString() ReadChar() WriteChar() Read one Char Write one Char.
Assembly Language Lecture 2. Lecture Outline Program Structure Memory models Data Segment Stack Segment Code Segment Input and Output Instructions INT.
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.
Computer Architecture and Assembly Language
1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A.
BYTE AND STRING MANIPULATON
What is an Operating System ?
Multiplication and Division Instructions
Assembly Language Programming Part 2
CS-401 Computer Architecture & Assembly Language Programming
(The Stack and Procedures)
9/17/2018 Kiến Trúc Máy Tính.
Stack and Subroutines Module M17.1 Section 11.2.
Microprocessor and Assembly Language
A Hexadecimal Calculator
(The Stack and Procedures)
Shift & Rotate Instructions)
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Unit:08 Software Interrupts
Multiplication and Division Instructions
Multiplication and Division Instructions
(The Stack and Procedures)
By Nasser Halasa Assembly Language.
Presentation transcript:

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 – (Table C-2) 2 – write char, 6 – write char, 9- write string (Table C-3) –Use Video BIOS (Int 10h) Functions 9 – write char and attribute, 0A- write char, … For Input –Use Irvine16 Functions Readchar, Readint, ReadHex, Readstring –Use DOS (Int 21h) Functions (Table C-2) 1 – read char, 6 – read char, 7- read char –Use Keyboard BIOS (Int 16h) Functions (Table C-5) 10 – wait for key

BR 6/002 Input/Output of Numbers A common task is to input or output numbers in ASCII format Output tasks: –Output an 8-bit value as ASCII string in HEX format –Output an 8-bit value as a ASCII string in BINARY format (see ‘pbin.asm’ example on WWW page) –Output an 8-bit value as ASCII string in DECIMAL format Input tasks: –Input a string representing an 8-bit number in Hex format –Input a string representing an two digit decimal number (unsigned)

BR 6/003 Output an 8 bit number in Hex Format Two Hex characters in 8-bits. Want to work with each set of 4-bits individually. Each Hex character represents 4-bits in a number. –0000 = ‘0’ (ASCII code = 30h) –0001 = ‘1’ (ASCII code = 31h) –1001 = ‘9’ (ASCII code = 39h) –…… –1010 = ‘A’ (ASCII code = 41h) –1011 = ‘B’ (ASCII code = 42h) –…… –1111 = ‘F’ (ASCII code) = 46h ). If 4-bits is between 0-9, then ASCII = 30h + 4bits If 4-bits is between A-F, then ASCII = 37h + 4bits

BR 6/004 Output an 8 bit number in Hex Format Approach: Write a subroutine called ‘Out1Hex’. This will output the lower 4 bits of register ‘AL’ as an Hex digit to the screen. To output an 8-bit value, the main routine(out2hex) will call ‘Out1Hex’ twice 1) for the most significant HEX digit, and 2) for the least significant Hex digit. out2hex proc ;; output value in ‘al’ as 2 hex character push ax ; save al shr al, 4 ; get most sig. 4 bits into lower call Out1Hex ; print most sig. hex digit pop ax ; get back original al and al, 0x0Fh ; upper 4 bits = 0 – working with low 4 bits call Out1Hex ; print least sig. hex digit out2hex endp

BR 6/005 Out1Hex Pseudo code for Out1Hex: if ( AL > 09H) jump to SKIP AL = AL + 30H Use Int21H, function2 to print character return skip: AL = AL + 37H Use Int21H, function2 to print character return

BR 6/006 Out1Hex A procedure to convert a 4-bit hex number to ASCII and print the character to the screen. Out1hexproc Cmpal, 9;is 4-bit value above 9? Jaischar;if so, must be a character Addal, 30h;if not, add 30h for conversion Jmpprintit;go to print label Ischar:add al, 37h;was character – add 37h for ;conversion Printit:movdl, al;printing a character to screen Movah,2;using int 21h, function 2. Int 21h Ret;return to main procedure Out1hex endp EndMain

BR 6/007 Output a 16-bit hex number? 32 bits? How would you print out a 16 bit value ? –Call Out1Hex 4 times. –Each call would have to have the 4 bits in the lower four bits of AL –You would have to start with the Most significant bits –After saving the value, use shr instruction to get the correct bits. How would you printout a 32-bit value? –Call ‘Out1Hex’ 8 times – once for each 4 bits of the 32- bit value.

BR 6/008 Output an 8-bit number in Decimal Format How would you output a number in Decimal format? Assume that AL contains a value between 0 and 99 and you want to print this out as a decimal value The value of the first digit is ‘AL divided by 10’ (quotient value of AL/10). The value of the 2 nd digit is REMAINDER of AL divided by 10!!

BR 6/009 Out1Dec A procedure to convert an 8-bit unsigned decimal number stored in AL to ASCII and print the character to the screen. Out1DecProc Push ax;save value And ah, ah;clear ah Div 10;divide value by 10 (quotient in AL, ;remainder in AH) Addal, 30h;convert 10’s digit to ASCII Callprintchar Moval, ah;get 1’s digit Addal, 30h;convert to ASCII Callprintchar Out1DecEndp

BR 6/0010 Input an 8-bit number in HEX format An 8-bit hex number will require two ASCII characters to represent it Need to get 4-bit value of digit from ASCII character code If ASCII is between 30H and 39H (‘0’ and ‘9’), then four-bit value is ASCII value – 30H. If ASCII is between 41H and 46H (‘A’ and ‘F’), then four-bit value is ASCII value – 37H

BR 6/0011 Input an 8-bit number in HEX format Assume AX has the two ASCII digits that represent a HEX number Example: AX = 4335 h, AH = 43h = ‘C’, AL=35h = ‘5’. Want to convert this to AL = C5h. in2hex proc push ax ;; save AX mov al,ah ;; get most sig. char into AL call inhex ;; convert ASCII hex code in AL to 4 bit value mov bl, al ;; save in BL pop ax ;; get AX back call inhex ;; convert ASCII hex code in AL to 4-bit value shl bl,4 ;; shift bl to left to move lower 4bit to upper or al, bl ;; combine upper and lower bits, AL has value! ret in2hex endp

BR 6/0012 inhex Subroutine Want to convert the ASCII code in AL that is a HEX digit to its 4-bit value Pseudo code: if (AL > 39h) jump to skip AL = AL - 30h return skip: AL = AL – 37H return

BR 6/0013 Input an 8-bit number in Decimal format Assume AX has the two ASCII digits that represent a DECIMAL number Example: AX = 3731 h, AH = 38h = ‘7’, AL=31h = ‘1’. Want to convert this to AL = 71 (decimal) = 47h !! Approach: a. Convert the most significant ASCII digit to its four bit value. b. Multiply this by 10 and save. c. Convert the least significant ASCII digit to its four bit value and ADD it to the value produced in ‘b’!! 71 = 7 * = 71 = 47 h.