I remember using a function called

geninterrupt(int interrupt_no) 

(included in dos.h) to display a string on the screen in turbo c++ . Now when I try to compile the same program with g++ the compiler yells at me.

C:\Users\Krish\Documents\rough.cpp|7|error: '_AH' was not declared in this scope|
C:\Users\Krish\Documents\rough.cpp|8|error: '_DX' was not declared in this scope|
C:\Users\Krish\Documents\rough.cpp|9|error: 'geninterrupt' was not declared in this scope|

It seems it doesn't even identify the registers. What am I doing wrong. Are these function not a part of c++ standard library? (should I explicitly link the libraries?). If yes how?

有帮助吗?

解决方案

Calling interrupts to get a string printed worked only on x86-compatible CPUs working in real mode (which DOS ran under). Modern operating systems work in protected mode in which BIOS interrupts are no longer available.

Today, console output is typically represented by a file handle to which you send data using standard library or, if you want to do it low-level, direct kernel functions. (In POSIX system the call is write)

From Linux System Call table you can use sys_write available under int 0x80 (You need to use inline assembly to fill the parameters and call the interrupt)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top