Using dos interrupts

Can anyone please help me with this program i am trying to write.
I am not very good at assembly code (i am used to 4th generation stuff) and I am trying to write a program that i will call test.com which i want to save to a file c:king.txt. When I call it I want to have a statement saying: My Favorite color is: 'input' then F1 to end it.

eg. My favourite colour is GREEN + [F1]

Then it will create a file C:king.txt and save the whole line as above in the file.


I have bits of it but i dont know how to fit it all together

msg db 'My favorite color is:$', 13, 10
.
.
.
mov SI, 00 ;I am not even sure if i should use a stack here?
mov ah, 01
int 21
mov [SI + 200], AL
.
.
.
.
mov ah, 3c
int 21
.
.
.
mov ah, 40
int 21


This probably sound simple to most so if anyone could help that would be so nice!

Comments

  • : Can anyone please help me with this program i am trying to write.
    : I am not very good at assembly code (i am used to 4th generation stuff) and I am trying to write a program that i will call test.com which i want to save to a file c:king.txt. When I call it I want to have a statement saying: My Favorite color is: 'input' then F1 to end it.
    :
    : eg. My favourite colour is GREEN + [F1]
    :
    : Then it will create a file C:king.txt and save the whole line as above in the file.
    :
    :
    : I have bits of it but i dont know how to fit it all together
    :
    : msg db 'My favorite color is:$', 13, 10
    : .
    : .
    : .
    : mov SI, 00 ;I am not even sure if i should use a stack here?
    : mov ah, 01
    : int 21
    : mov [SI + 200], AL
    : .
    : .
    : .
    : .
    : mov ah, 3c
    : int 21
    : .
    : .
    : .
    : mov ah, 40
    : int 21
    :
    :
    : This probably sound simple to most so if anyone could help that would be so nice!
    :
    [GREEN]
    Here's a bit of Nasm code that creates, writes, & closes a file.
    An ASCIZ file name is a valid name in a string with a nul-0 ending.
    FNAME DB "KING.TXT",0
    FNAME DB "C:KING.TXT",0 ; might work too.

    PROC FCWC File Create, Write, Close
    Takes as input: file name address, string to write address, & size.
    Maybe there's something usefull in there for ya.
    Bitdog[/GREEN]

    [code]
    ;FCWCm = File Create, Write, Close, macro
    ; FCWCm FNAME,BUFADR,SIZE
    %macro FCWCm 3
    PUSH AX
    PUSH CX
    PUSH DX
    MOV DX,%1 ;; DS:DX address of ASCIZ filename
    MOV AX,%2 ;; address of bytes to write
    MOV CX,%3 ;; amount of bytes to write
    CALL FCWC ;; File Create, Write, & Close
    POP DX
    POP CX
    POP AX
    %endmacro

    ; Recieves:
    ; DX = Filename address (ASCIZ)
    ; AX = address of buffer to write
    ; CX = amount of bytes to write
    ;Returns: CF set on error, JC ERROR
    align 16
    FCWC:
    PUSH BX
    PUSH AX ; address
    PUSH CX ; size
    MOV AH,3Ch ; overwrite existing file
    MOV CX,32 ; archive type 32
    INT 21h ; create archive type file FCREATAm FNAME
    JC FWdone ; never fails unless bad input file name

    POP CX ; size
    POP DX ; address DS:DX
    PUSH AX ; save file handle
    MOV BX,AX
    MOV AH,40h
    INT 21h ; FWRITEm

    POP BX ; file handle
    MOV AH,3Eh
    INT 21h ; FCLOSEm
    CLC ; clear CF Carry Flag
    FWdone:
    POP BX ; JC ERROR
    RET
    [/code]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion