Jump to content
  • Advertisement
Sign in to follow this  

Machine code question

This topic is 4443 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am creating a new language and am using my compiler to translate my language into machine code. I know allot but can't figgure out how to print to the screen. Does anyone know how to do this.

Share this post

Link to post
Share on other sites
You can't figure out how to print to the screen?

As in, you don't know the assembly required to print to the screen?

Well, as far as I know, that would include getting access to the video buffer, and editing that directly. I recommend that you use C, or another language as the backend to your language.

It would also probably be easier to just create a small scripting language instead of a full-blown compiled to machine code language.

Anyway, that being said, good luck.

Share this post

Link to post
Share on other sites
Assuming win32/x86...

You can try int21 (iirc).


stack ENDS
greet DB 'Hello, world!$'
dseg ENDS
start PROC FAR
mov ax,dseg
mov ds,ax
mov dx,OFFSET greet
mov ah,09H
int 21H
mov ah,4CH
int 21H
start ENDP
cseg ENDS
END start

or so.

Share this post

Link to post
Share on other sites
Without DOS's interrupt 21h, you could write directly to address: 0xB8000.

Example (untested, dunno if it will build, NASM syntax):

mov ebx, 0xB8000
mov es, ebx
mov [es:0], 'L' ;write the letter L to the upper left of the screen

Note that every other byte represents an ASCII character. The bytes in-between are 'attributes' (for color and blinking.)

My recommendation to you is to make your compiler more cross-platform by linking your output object files to C standard libraries (or base your own libraries around them.)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!