There is an assembler code for Borland Turbo Pascal:

procedure cursOFF; Assembler; asm mov ah,01; mov cx,$2000; int 10h; end; 

procedure cursON; Assembler; asm mov ah,01; mov cx,$0fff; int 10h; end;

These procedures are used to hide and show the cursor. When trying to compile a program that uses the above code in the FreePascal compiler, a lot of errors occur. As I understand it, some features are used to implement the asm code in FreePascal. Help to adapt the code to work in FreePascal.
Py.Sy .: Sori that bother so ancient programming, solve the problem Pts. Nun.

  • I prescribe: <pre> <code> {$ ASMMODE intel} </ code> </ pre> and compile the rules, but when I call the procedure, I exit with error code 216. - uzumaxy
  • 2
    ASM is not ancient programming! ASM - always relevant. Even if you solve a problem for an 8086 compatible processor ... - gote

1 answer 1

According to the documentation (http://freepascal.ru/article/freepascal/20050418171713/) you need to write {$ ASMMODE intel} because The default AT & T syntax is as in GNU Assembler. Try replacing intel with direct. Here is a description (from the same place):

• DIRECT - means that the asm-insert will be directly copied to the intermediate asm-code. This option may be useful when used in conjunction with the {$ OUTPUT_FORMAT ...} directive, in order to use all the features of the external assembler in the insert.

still look here

 01H уст. размер/форму курсора (текст). курсор, если он видим, всегда мерцает. вход: CH = начальная строка (0-1fH; 20H=подавить курсор) CL = конечная строка (0-1fH) <--------------------------- 

Perhaps the problem is this.

  • one
    those. replace mov cx, $ 0fff; on mov cx, $ 001f; - gote
  • The compiler curses the DIRECT mode: Illegal assembler style specified "DIRECT". <br> Replacing mov cx, $ 0fff; on mov cx, $ 001f; Intel mode does not help. We get exitcode 216 ... <br/> Anyway, thank you very much for the answer. - uzumaxy
  • one
    try to save the used registers and restore them at the end of the procedure ... push ax; push cx; ...; int 10h; pop cx; pop ax or ALL registers - pusha ... popa - gote
  • one
    In general, I installed FreePascal ... I checked the code. Problem: You, probably, just like me, use the Win32 compiler and the Compile Target in your Win32. According to the trace results, everything falls on the int 10h call (Segmentation Fault). Most likely, this is due to an attempt to call a BIOS interrupt from the Protected mode of the processor ... It is necessary to compile the program for DOS and run accordingly. I don’t know how to do this in FreePascal :( - tried to install FreePascal for GO32 DOS ext - does not compile ... :( - gote
  • one
    Happened! Uninstall FreePascal for Win32 and install FreePascal for GO32 DOS (something like that). Compile your program in it with Compile -> Target = GO32 DOS ... Checked - Everything works. WinXP SP3 - gote