我正在阅读有关在DOS中以VGA-256颜色打印组装字符的教程。我正在阅读的教程是用Pascal编写的,我对这种语言的经验很少,我所有的VGA程序都使用C语言。
我的问题是关于用于访问每个字符的位图的标签。在帕斯卡,他们有这个:
procedure chr6x7_dat; assembler;
asm
db $00,$00,$00,$00,$00,$00,$00,$00,$20,$20,$20,$20,$00,$20,$00,$50
db $50,$00,$00,$00,$00,$00,$50,$f8,$50,$50,$f8,$50,$00,$20,$f8,$a0
db $f8,$28,$f8,$00,$c8,$d0,$20,$20,$58,$98,$00,$40,$a0,$40,$a8,$90
db $68,$00,$20,$40,$00,$00,$00,$00,$00,$20,$40,$40,$40,$40,$20,$00
db $20,$10,$10,$10,$10,$20,$00,$50,$20,$f8,$20,$50,$00,$00,$20,$20
db $f8,$20,$20,$00,$00,$00,$00,$00,$60,$20,$40,$00,$00,$00,$f8,$00
db $00,$00,$00,$00,$00,$00,$00,$60,$60,$00,$00,$08,$10,$20,$40,$80
db $00,$70,$88,$98,$a8,$c8,$70,$00,$20,$60,$20,$20,$20,$70,$00,$70
db $88,$08,$70,$80,$f8,$00,$f8,$10,$30,$08,$88,$70,$00,$20,$40,$90
db $90,$f8,$10,$00,$f8,$80,$f0,$08,$88,$70,$00,$70,$80,$f0,$88,$88
db $70,$00,$f8,$08,$10,$20,$20,$20,$00,$70,$88,$70,$88,$88,$70,$00
db $70,$88,$88,$78,$08,$70,$00,$30,$30,$00,$00,$30,$30,$00,$30,$30
db $00,$30,$10,$20,$00,$00,$10,$20,$40,$20,$10,$00,$00,$f8,$00,$f8
db $00,$00,$00,$00,$20,$10,$08,$10,$20,$00,$70,$88,$10,$20,$00,$20
db $00,$70,$90,$a8,$b8,$80,$70,$00,$70,$88,$88,$f8,$88,$88,$00,$f0
db $88,$f0,$88,$88,$f0,$00,$70,$88,$80,$80,$88,$70,$00,$e0,$90,$88
db $88,$90,$e0,$00,$f8,$80,$f0,$80,$80,$f8,$00,$f8,$80,$f0,$80,$80
db $80,$00,$70,$88,$80,$98,$88,$70,$00,$88,$88,$f8,$88,$88,$88,$00
db $70,$20,$20,$20,$20,$70,$00,$10,$10,$10,$10,$90,$60,$00,$90,$a0
db $c0,$a0,$90,$88,$00,$80,$80,$80,$80,$80,$f8,$00,$88,$d8,$a8,$88
db $88,$88,$00,$88,$c8,$a8,$98,$88,$88,$00,$70,$88,$88,$88,$88,$70
db $00,$f0,$88,$88,$f0,$80,$80,$00,$70,$88,$88,$a8,$98,$70,$00,$f0
db $88,$88,$f0,$90,$88,$00,$70,$80,$70,$08,$88,$70,$00,$f8,$20,$20
db $20,$20,$20,$00,$88,$88,$88,$88,$88,$70,$00,$88,$88,$88,$88,$50
db $20,$00,$88,$88,$88,$a8,$a8,$50,$00,$88,$50,$20,$20,$50,$88,$00
db $88,$50,$20,$20,$20,$20,$00,$f8,$10,$20,$40,$80,$f8,$00,$60,$40
db $40,$40,$40,$60,$00,$00,$80,$40,$20,$10,$08,$00,$30,$10,$10,$10
db $10,$30,$00,$20,$50,$88,$00,$00,$00,$00,$00,$00,$00,$00,$00,$f8
db $00,$f8,$f8,$f8,$f8,$f8,$f8
end;
我希望在C中有一个类似的标签,因此我可以在内联汇编命令中访问它,以根据ASCII值计算偏移量。但是我不知道如何声明我在C中发布的内容。
谁能帮我吗?
最佳答案
通过pascal $
char用于定义hexadecimals
如果要在c中定义它,只需创建一个uint8_t
的数组/矩阵,并用pascal值将其初始化,并用$
替换0x
$F5
将是0xF5
关于c - 在C中使用内联汇编:在数据段中分配标签,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34657780/