Page 1 of 1

How to I/O in ASSEMBLER

PostPosted: April 30th, 2004, 10:47 am
by newbie
Hello everybody,

I NEED your help. I want to translate delphi codes below to ASSEMBLY language.

1. The procedure to extract embedded files
-------
procedure ExtractFile;
var RS : TResourceStream;
begin
RS := TResourceStream.Create(HInstance, 'group', 'file');
try
RS.SaveToFile('FilePath');
finally
RS.Free;
end;
end;

2. The procedure to write a text file
------
procedure SaveFile;
var mytext : TextFile;
begin
AssignFile(mytext, 'FilePath');
Rewrite(mytext);
WriteLn(mytext, 'line1');
WriteLn(mytext, 'line2');
CloseFile(mytext);
end;
------

I'm Expecting Your Reply. Thank You In Advanced.

an example

PostPosted: April 30th, 2004, 10:52 am
by newbie
I have the program below but I don't know how to use it in Delphi envirnment

; The program creates a file "Test.txt" and writes "Some text"
; in it. Creation takes place in the current directory.



org 100h
start:
mov ah,3Ch ; create file
xor cx,cx ; sets the file attribute
lea dx,file ; gets the file name
int 21h

mov ax,3d02h ; open file read/write
lea dx,file ; gets the file name
int 21h

mov handle,ax

mov ah,40h ; write to file
mov bx,handle
mov cx,9 ; text len
lea dx,text ; text adress
int 21h

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

ret

file db 'Test.txt',0 ; file name
handle dw 0
text db 'Some text' ; text to be written in the file

end

PostPosted: May 1st, 2004, 7:30 am
by Kambiz
The assembly code above uses a DOS function (INT 21), and is obsolete.

If you are going to create a file on Windows, I do recommend to follow Delphi/Windows rules.