Writing and reading files. Creating a file on a disk Get a file handle from system Use INT 21H function 3C to create a directory entry for the file Use.

Slides:



Advertisements
Similar presentations
Defining and processing tables
Advertisements

Program.-(9)* Write a program Input two numbers from keyboard and multiply of given values using by variables. Input value No 1 input value No2 Multiply.
Array : To store multiple value in one variable, “but value must be homogenous or similar type” is called array. We can say in other word Arrangement of.
Program.(08) Write a program Divide 5 by 2 and display answer value and remainder value. 1 Store 5 into AL 2 Store BL into 2 3Divide AL Into BL 4Store.
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.
A Design Example An Exact Calculator. Exact Calculator Manipulating Large Integer Values Operations: – +, -, *, /, %, And, Or, Xor, Not, Power Functions.
Introduction to Computer Engineering by Richard E. Haskell Multiplication and Division Instructions Module M16.4 Section 10.4.
ICS312 Set 6 Operands. Basic Operand Types (1) Register Operands. An operand that refers to a register. MOV AX, BX ; moves contents of register BX to.
More about procedures and Video Processing. Lesson plan Review existing concepts More about procedures and boolean expression Video processing.
MS DOS File IO Text chapter 13. DateTime C:\MASM615>make16 datetime Assembling: datetime.asm Volume in drive C has no label. Volume Serial Number is 07D
Flow Diagram: Push flags, CS, IP Pop IP,CS,flags Push AX,BX,CX,DX,ES,DS,SI,DI,BP POP BP,DI,SI,DS,ES,DX,CX,BX,AX.
Multiplication and Division
Direct video practice and Keyboard Operations
Chapter 9 Using Disks and Files Objectives: The difference between Floppy and Hard Disks What the Boot Sector is for What the File Allocation Table is.
Flow Control Instructions
Assembly Language for Intel-Based Computers Chapter 13: 16-Bit MS-DOS Programming Kip R. Irvine.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 13: 16-Bit MS-DOS Programming (c) Pearson Education, All rights reserved. You may.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
Factorial of a number data segment x1 db 4 fact dw ? data ends
Assembly Programming Timothy C. Rice Jr., MIT. OUTLINE Basic Structure Exit to Dos Print Character Clear Screen Change BG & FG Color Set Curser Location.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7)
ECE291 Computer Engineering II Lecture 13 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 13: 16-Bit MS-DOS Programming (c) Pearson Education, All rights reserved.
Assembly Language for x86 Processors 6th Edition
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
Assembly Language for Intel-Based Computers Chapter 13: 16-Bit MS-DOS Programming Kip R. Irvine.
9.1 – 9.3 Solving Right Triangles without Trigonometry.
“It was the night before midterm”. Midterm rule (March 16 nd, 2005) - Student ID is required. Open books, note exam - Don’t: - Leave the exam room after.
Strings, Procedures and Macros
File I/O MS-DOS Interrupt 21h has many functions dealing with file and directory I/O services. Both MS-DOS and MS_Windows use 16- bit integers called HANDLES.
Executing and Linking an assembly program. Lesson plan Review Program logic and control Practice exercise Assembling, Linking and Executing Programs Practice.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
Writing and Reading Files Methods for processing disk files File Control Blocks (FCBs) –Supported by DOS –Can address drives and filenames.
Processing String Data and Binary Data (continue)
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:
ACOE251Sofware Constructs1 Software Constructs What they are …..
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.
Review of Assembly language. Recalling main concepts.
Chapter Bit MS-DOS Programming Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Control Structure vs. Assembly Language NASM. If-then-else If conditional then then_actions jump to endif else else_actions endif.
File Operations. FILE PROCESSING For the purposes of the following discussion, reading means copying all or part of an existing file into memory Writing.
SAT/ACT MATH UNIT 10 Equation with More Than One Variable.
Assembly language programming
Format of Assembly language
Presentation on Real Mode Memory Addressing
1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A.
Lecture 4 Control Flow Structures (LOOPS)
Assembly IA-32.
(The Stack and Procedures)
9/17/2018 Kiến Trúc Máy Tính.
שפת סף וארכיטקטורה של מעבד 8086
فصل پنجم انشعاب و حلقه.
Subroutine Call; Stack
8086 Registers Module M14.2 Sections 9.2, 10.1.
اصول اساسی برنامه نویسی به زبان اسمبلی
A Hexadecimal Calculator
Microprocessor Lab CSL1543 0:0:2
(The Stack and Procedures)
Microprocessor Lab CSL1543 0:0:2
Unit:08 Software Interrupts
X86 Assembly Review.
COMP2012H: OOP and DS (honors track)
Assembler Directives end label end of program, label is entry point
High-level language structures
UNIT-II Assembly Language Programs Involving Logical
(The Stack and Procedures)
Jump & Loop instructions
Part VI Looping Structures
Presentation transcript:

Writing and reading files

Creating a file on a disk Get a file handle from system Use INT 21H function 3C to create a directory entry for the file Use INT 21H function 40H to write records to the file Use INT 21H function 3EH to close the file

Create a file filename DB 'data.dat',0 handle DW ? prompterror DB 'Error while creating this file ','$'

INT 21H function 3CH mov cx, 0 ; File attribute LEA dx, filename mov ah, 3ch int 21h jc err mov filehandle, ax jmp exit err: MOV AH, 09H LEA DX, prompterror INT 21H

File attribute File attribute defines the type of file. One file may have more than one attribute 00H: normal file 01H: read only file 02H:hidden file 04H: system file (more information, please see page 301)

INT 21H Function 40H MOV Ah, 40H MOV BX, filehandle MOV CX, 256 ; number of bytes to write to disk LEA DX, DISKAREA ; the area to write to disk INT 21H JC error CMP AX, 256 JNE error

INT 21H function 3EH: close file MOV AH, 3EH MOV BX, filehandle INT 21H JC error

Reading a file Use INT 21H function 3Dh to open a file Use INT 21H function 3FH to read records from the file Use INT 21H function 3EH to close a file

Open a file using INT 21H function 3DH 000: read only 001: write only 010: read/write

Open file for reading MOV AH, 3DH MOV AL, 00H ; Access code = 00 = read only LEA DX, FILENAME INT 21H JC error MOV filehandle, AX Data: filehandle DW ?

INT 21H function 3F – Read record Data: Filehandle DW ? INAREA DB 512 DUP(‘ ‘)

Code MOV AH, 3FH MOV BX, filehandle MOV CX, 512 LEA DX, inarea INT 21H JC error CMP AX, 00 JE exit

Final exam Date: Tuesday May 9, 10am-12pm Open book Format (multiple choices, problem solving, determine the errors from code, 2 programming problems) Focus: everything from Week 1 to Week 14