Assembly: how to read data from file and and store it in memory

Assembly: how to read data from file and and store it in memory

Page 1 of 1

2 Replies - 8011 Views - Last Post: 19 November 2009 - 08:56 PM

#1 dhyabi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-November 09

Assembly: how to read data from file and and store it in memory

Posted 11 November 2009 - 09:01 AM

here is my code but it is not working
Please any help


CDSEG SEGMENT PARA public 'code'
ASSUME CS:CDSEG, DS:CDSEG
ORG 100H
START:
JMP MAIN

info	db	10	dup(0)
filename	db	'data.txt'
handle	dw	?

MAIN:
;opening existing file
mov dx,offset filename
mov al,0
mov ah,3dh
int 21h
jc cant_open
mov handle,ax

;reading file
mov ah,3fh
mov bx,handle
mov cx,10
mov dx,offset info
int 21h

;close file
mov bx,handle
mov ah,3eh
int 21h

cant_open:

MOV AX,4C00H
INT 21H
CDSEG ENDS
END START
 

This post has been edited by dhyabi: 11 November 2009 - 09:02 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Assembly: how to read data from file and and store it in memory

#2 calvinthedestroyer  Icon User is offline

  • D.I.C Lover

Reputation: 167
  • View blog
  • Posts: 1,908
  • Joined: 13-October 07

Re: Assembly: how to read data from file and and store it in memory

Posted 19 November 2009 - 05:09 PM

hmm, you will need to copy your file from the hard drive to RAM.
once its in RAM you can use the address in RAM to access that data.

so, there's allot to do

A friend on mine wrote a C++ program that opened files for him and then passed the data to his masm program.

This post should get moved to "assembly"
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5314
  • View blog
  • Posts: 27,220
  • Joined: 10-May 07

Re: Assembly: how to read data from file and and store it in memory

Posted 19 November 2009 - 08:56 PM

** Moved to Assembly **
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1