port???

hi,

whenever i try to compile a program that uses a port[$...] the compiler will say "Identifier not found, PORT". is there some unit ide need in the uses area?? if not then what should i do?

thanx

Comments

  • : hi,
    :
    : whenever i try to compile a program that uses a port[$...] the compiler will say "Identifier not found, PORT". is there some unit ide need in the uses area?? if not then what should i do?
    :
    : thanx
    :

    Are you sure you are using it correcly?
    (post few lines of code as an example)

    which pascal you are using? turbo pascal? version xx?

    Iby





  • : hi,
    :
    : whenever i try to compile a program that uses a port[$...] the compiler will say "Identifier not found, PORT". is there some unit ide need in the uses area?? if not then what should i do?
    :
    : thanx
    :
    There are no units for this since it is a basic part of the language. Are you using FreePascal? I've heard that it doesn't support PORT yet. If so, then it shouldn't be too hard to access the port through assembler. Wait, don't run away. Here's an example. Just say you want to get input from port $60 to a byte variable called key. The two pieces of code below will do the same thing:

    {With PORT}
    Key := Port[$60];

    {Without PORT}
    Asm
    In Key,$60
    end;

    If you wanted to send info to the port $60 instead, the code would look like this:

    Asm
    Out $60,Key
    end;

  • yeah, i am using freepascal so i guess that explains why it doesnt work. But when i tried compiling the asm code it still wouldnt compile...

    Error: Asm: [in mem8,imm8s] invalid combination of opcode and operands

    dont goto any trouble over this issue. im not in desperate need to get it working (still *reasonably* new at pascal)

    thanx





  • : yeah, i am using freepascal so i guess that explains why it doesnt work. But when i tried compiling the asm code it still wouldnt compile...
    :
    : Error: Asm: [in mem8,imm8s] invalid combination of opcode and operands
    :
    : dont goto any trouble over this issue. im not in desperate need to get it working (still *reasonably* new at pascal)
    :
    : thanx
    :
    Okay, somewhere in the options there is a place where you set the assembly style. Check that it's set to Intel-style assembly. I don't think this is your problem, but you should make sure anyway.

    Now your imm8s is a variable, isn't it? That might be the problem. Instead, try something like this:
    MOV DX,imm8s
    IN mem8,DX

    I'm not sure which instruction set FreePascal uses, so if that still doesn't work try this:
    MOV DX,imm8s
    IN AL,DX
    MOV mem8,AL

  • : : yeah, i am using freepascal so i guess that explains why it doesnt work. But when i tried compiling the asm code it still wouldnt compile...
    : :
    : : Error: Asm: [in mem8,imm8s] invalid combination of opcode and operands
    : :
    : : dont goto any trouble over this issue. im not in desperate need to get it working (still *reasonably* new at pascal)
    : :
    : : thanx
    : :
    Oh, sorry. That was the error message, not what you actually typed. I misinterperated. The thing is that you should move the number of the port to the DX and, if you are doing output, the value you want to send to the port to the AL register. Hope this makes sensse to you. Here are two proper translations from Pascal to assembly:

    EXAMPLE 1
    Pascal:
    Port[$3C9]:=50;

    Assembly:
    mov dx,$3C9
    mov al,50
    out dx,al

    EXAMPLE 2
    Pascal:
    MyVar := Port[$3C9];

    Assembley:
    mov dx,$3C9
    in al,dx
    mov MyVar,al

  • problem...every time i try to compile assembly it will say that it cant find the identifiers AX,DX or any that are mentioned in the assembly code. BUT i recently found that i can install Turbo pascal so i did that and port is now working fine. Also TP gives off much smaller and faster running exes than FPC. So thanks for everything jaywalk.

    P.S Dont bother trying to solve this assembly problem i got going cos i dont think il be doing that for a long time now ;)

  • : problem...every time i try to compile assembly it will say that : it cant find the identifiers AX,DX or any that are mentioned in : the assembly code...

    I quess that freepascal used to AT&T syntax. In this syntax all registers name starting with "%". Also in AT&T syntax source and destination points are exchanged (in comparation with Intel one)... for example "mov 0x60,%cx". If you would like to use 32bit registers you have to use appendix "l" in many instructions... (for example - movl 0x01, %ecx)...

    --tyruk



  • : : problem...every time i try to compile assembly it will say that : it cant find the identifiers AX,DX or any that are mentioned in : the assembly code...
    :
    : I quess that freepascal used to AT&T syntax. In this syntax all registers name starting with "%". Also in AT&T syntax source and destination points are exchanged (in comparation with Intel one)... for example "mov 0x60,%cx". If you would like to use 32bit registers you have to use appendix "l" in many instructions... (for example - movl 0x01, %ecx)...
    :
    : --tyruk
    :
    It does use AT&T by default, but go to the options menu, select Compiler, and then choose the Assembler tab and you can change it to Intel-style there.

  • : problem...every time i try to compile assembly it will say that it cant find the identifiers AX,DX or any that are mentioned in the assembly code. BUT i recently found that i can install Turbo pascal so i did that and port is now working fine. Also TP gives off much smaller and faster running exes than FPC. So thanks for everything jaywalk.
    :
    : P.S Dont bother trying to solve this assembly problem i got going cos i dont think il be doing that for a long time now ;)
    :
    I must admit, TP is much easier to use than FP, even if it only makes real-mode programs.

    But you really should try learning assembly. It's a lot easier than one would imagine, and it gives you amazing abilities. You can make a computer do anything that a computer can possibly do. That asm problem you had in FP was just because of compiler settings, nothing serious.

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