0

I'm programming a chat between 2 computer using the serial cable, this is my first time using assembly. I've been working so far on the interface without problems, i'm using NASM to compile the .asm into .com files and then run them.

Now I started working with the serial port and wrote this simple program to send a string character by character and check using hyperterminal if it does in fact gets sent.

org 0x0100

    mov ah, 0
    mov al, 0xe3            ;port parameters
    mov dx, 0               ;port numbe (COM 1)
    int 0x14                ;initialize port

    mov si, msg
    mov cx, [length]




l:  mov ah,0x1
            lodsb           ;loads next character
    int 0x14                ;sends character
    loop l

    mov ax,0x4c00
    int 0x21



    msg: db 'hello world'

    length: dw 11

But when i run the .com file i get this msg:"the system cannot open com1 port requested by the application". I read that running it in compatibility might fix this.

So, is it possible to run a .com file in compatibility mode? Will i have to make .exe file to run in compatibility mode? If so, i know that you have to generate a .obj before the .exe but nasm won't let me do a .obj of the code above, i believe the code needs a different format like a main use instead of the org0x0100 but that's not clear for me, as i have looked it up but everybody does different things.

4

1 回答 1

2

In your code , you use the so called DOS interrupts (e.g. int 0x21 for program termination to the screen) so you must work under x86 RealMode , there is a nifty tool for emulating DOS application (like the one you use) and its called DOSBox, please use it.

于 2013-03-30T19:00:49.657 回答