Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ada and assembly

Tags:

x86

assembly

ada

I'm looking at making a hardware debug tool that runs on the bare CPU (x86), 32-bit protected mode and no OS. Due to time constraints, I won't be writing the tool all in x86 assembly. I like the Ada language (but am inexperienced with it) and thought it might be interesting to use Ada rather than C for this project.

With C one can use inline assembly or call subprograms written in assembly to access the BIOS for basic things like keyboard I/O or displaying text on the screen. Does Ada have a similar capability? And if so, does anyone know of any resources or tutorials for calling assembly methods and linking with them?

like image 897
Dr. Watson Avatar asked May 21 '09 03:05

Dr. Watson


2 Answers

You can use inline assembly code in Ada. You need to use the System.Machine_Code package which provides the (overloaded) Asm function.

like image 105
Michael Carman Avatar answered Sep 29 '22 07:09

Michael Carman


The GNAT Reference manual has a section on Machine Code Insertions, and while it's GNAT-specific, one should be able to get a general sense of how it works even if you're using a different compiler.

like image 39
Marc C Avatar answered Sep 29 '22 07:09

Marc C