簡體   English   中英

C ++:調用BIOS中斷0x21

[英]C++ : calling BIOS interrupt 0x21

我記得使用了一個叫做

geninterrupt(int interrupt_no) 

(包含在dos.h )以在Turbo c ++中在屏幕上顯示字符串。 現在,當我嘗試使用g ++編譯同一程序時,編譯器對我大吼大叫。

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|

似乎它甚至無法識別寄存器。 我究竟做錯了什么。 這些功能不是c ++標准庫的一部分嗎? (我應該明確鏈接這些庫嗎?)。 如果是,怎么辦?

調用中斷以獲取打印的字符串僅在以real mode (DOS在其下運行)下工作的x86兼容CPU上有效。 現代操作系統在protected mode工作,在該protected mode BIOS中斷不再可用。

如今,控制台輸出通常由file handle表示,您可以使用標准庫將數據發送到該file handle ,或者如果要進行低級直接內核功能,也可以將數據發送到該file handle (在POSIX系統中,調用為write

Linux系統調用表中,您可以使用int 0x80下的sys_write (您需要使用內聯匯編來填充參數並調用中斷)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM