How to I/O in ASSEMBLER

Please discuss general Delphi programming topics here.

How to I/O in ASSEMBLER

Postby newbie » April 30th, 2004, 10:47 am

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.
newbie
Active Member
Active Member
 
Posts: 6
Joined: January 2nd, 2004, 12:13 pm

an example

Postby newbie » April 30th, 2004, 10:52 am

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
newbie
Active Member
Active Member
 
Posts: 6
Joined: January 2nd, 2004, 12:13 pm

Postby Kambiz » May 1st, 2004, 7:30 am

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.
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 8 guests

cron