汇编代码帮助(创建新文件)

发布于 2024-12-19 12:36:34 字数 594 浏览 2 评论 0原文

我是装配新手。我必须编写一个程序,将输入文件的数据复制到输出文件。但必须创建此输出文件。

问题是我无法创建这个看起来如此简单的文件。

我使用的代码是

.model tiny
.data

outputfile db "newfile.txt",0   
outhandle dw ?  
        .code
.stack
    cseg segment 'code'
assume cs:cseg, ds:cseg
org 100h
start:
create_a_file:
 mov dx, offset outputfile
 mov cx, 0
 mov ah, 3Ch
 int 21h
 mov outhandle, ax
jc error_routine
mov ah, 3Eh
 mov bx, outhandle
 int 21h

error_routine:
mov ax, 4c00h
 int 21h
 cseg ends
end start

我在任何地方都看不到新文件。即使我指定了确切的根文件夹,例如“c:...” 我不知道出了什么问题。 如有任何帮助,谢谢 PS:我使用的是 Windows XP 32 位。和 TASM(便携式)

I'm new in assembly. I have to do a program that copies the data of an input file to an out put file. but this output file has to be created.

The problem is that I cannot create this file which seems to be so straight forward.

the Code i am using is

.model tiny
.data

outputfile db "newfile.txt",0   
outhandle dw ?  
        .code
.stack
    cseg segment 'code'
assume cs:cseg, ds:cseg
org 100h
start:
create_a_file:
 mov dx, offset outputfile
 mov cx, 0
 mov ah, 3Ch
 int 21h
 mov outhandle, ax
jc error_routine
mov ah, 3Eh
 mov bx, outhandle
 int 21h

error_routine:
mov ax, 4c00h
 int 21h
 cseg ends
end start

I see the new file nowhere.Even when I specify the exact root folder like "c:..."
I cant figure out what is going wrong.
Any help is appriciated, Thanx
PS: Im using windows XP 32-bit. and TASM (portable)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

追星践月 2024-12-26 12:36:34

如果您的目的是创建 .COM 程序,请将源代码简化为:

cseg segment 'code'
    assume cs:cseg, ds:cseg, es:cseg, ss:cseg
    org 100h
start:

create_a_file:
    mov dx, offset outputfile
    mov cx, 0
    mov ah, 3Ch
    int 21h
    mov outhandle, ax
    jc  error_routine

    mov ah, 3Eh
    mov bx, outhandle
    int 21h

error_routine:
    mov ax, 4c00h
    int 21h

outputfile db "newfile.txt",0   
outhandle dw ?  

cseg ends

end start

将程序编译为 tasm.exe myprog.asm 并将其链接为 tlink.exe /t myprog.obj。您应该获得 myprog.com 并且它应该可以很好地创建 NEWFILE.TXT

If your intention is to create a .COM program, simplify the source code to this:

cseg segment 'code'
    assume cs:cseg, ds:cseg, es:cseg, ss:cseg
    org 100h
start:

create_a_file:
    mov dx, offset outputfile
    mov cx, 0
    mov ah, 3Ch
    int 21h
    mov outhandle, ax
    jc  error_routine

    mov ah, 3Eh
    mov bx, outhandle
    int 21h

error_routine:
    mov ax, 4c00h
    int 21h

outputfile db "newfile.txt",0   
outhandle dw ?  

cseg ends

end start

Compile the program as tasm.exe myprog.asm and link it as tlink.exe /t myprog.obj. You should get myprog.com and it should create NEWFILE.TXT just fine.

信愁 2024-12-26 12:36:34

检查您的 tasm/bin 文件夹。您的“newfile.txt”可能在那里

Check your tasm/bin folder. Your "newfile.txt" may be there

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文