![ישן](https://static.fresh.co.il/images/vBulletin/statusicon/post_old.gif)
10-05-2008, 11:51
|
|
|
חבר מתאריך: 27.10.02
הודעות: 2,038
|
|
שאלה באסמבלי 8086
מטרת התוכנית היא כרגע ליצור קובץ code.txt שאליו היא תעתיק את הפקודות מהתוכנית עצמה.
ככה זה נראה
קוד:
P286N
IDEAL
DOSSEG
MODEL small
STACK 100H
DATASEG
filename DB "code.txt", 0
fd DW ?
CODESEG
start:
mov ax, @data
mov ds, ax
; create the file and open for write
mov ah, 3CH
mov cx, 0
lea dx, [filename]
int 21H
mov [fd], ax
; write the code to the file
mov ah, 40H
mov bx, [fd]
mov cx, ?
mov dx, offset start
int 21H
; close the file
mov bx, [fd]
mov ah, 3EH
int 21H
exit:
mov ah, 4CH
mov al, 0
int 21H
END start
הקובץ code.txt אכן נוצר, אך הוא לא מכניס לי דבר לתוך הקובץ! למה? מישהו מאתר את הבעיה?
משום מה אני אפילו לא מצליח להכניס סטרינג רגיל לקובץ! תראו:
קוד:
P286N
IDEAL
DOSSEG
MODEL small
STACK 100H
DATASEG
filename DB "code.txt", 0
fd DW ?
msg DB "Hello World!", 0
CODESEG
start:
mov ax, @data
mov ds, ax
; create the file and open for write
mov ah, 3CH
mov cx, 0
lea dx, [filename]
int 21H
mov [fd], ax
; write the code to the file
mov ah, 40H
mov bx, [fd]
mov cx, ?
mov dx, offset word msg
int 21H
; close the file
mov bx, [fd]
mov ah, 3EH
int 21H
exit:
mov ah, 4CH
mov al, 0
int 21H
END start
מישהו רואה איפה הבעיה?
תודה מראש!
|