3

I wrote a program in assembler and compiled it. It is meant to print a blue smiley face and then wait for the user to press a key before it terminates. It does do that last bit but it doesn't print the smiley face. Can someone explain what have I done wrong ?

CSEG segment
org 100h
Begin:

mov ax,0B800h
mov es,ax
mov di,0

mov ah,31
mov al,1
mov es:[di],ax

mov ah,10h
int 16h

int 20h

CSEG ends
end Begin

I compiled it with MASM with a 16 bit linker

Kristina
  • 15,859
  • 29
  • 111
  • 181

3 Answers3

1

You can only poke the video buffer directly if you're in a text-only video mode. I'm guessing that you're using Windows of some kind and not actually booting DOS, so you probably are in a graphics mode.

What you may be able to do is open a console window and then AltEnter to go to a full-screen text mode. Try running your program there.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • i tried doing that in DOSbox and it didn't seem to help. the character still isn't appearing – Kristina Dec 20 '09 at 23:45
  • 1
    Actually, even if you're running this in Windows, the NTVDM 16-bit loader probably virtualises the access to the character mode frame buffer. However, I don't recall whether it actually does or not. – Greg Hewgill Dec 20 '09 at 23:45
  • 1
    Also, make sure you're looking in the *top left corner* of your screen. That's where you're putting the smiley face. – Greg Hewgill Dec 20 '09 at 23:48
  • Um yeah , it does work in dosbox. No luck running it on NTVDM though :( – Kristina Dec 20 '09 at 23:55
0

It's been about a year or so since I worked with MASM and the only reference book I have at home is MIPS, so I'm admittedly a bit rusty, however print to screen requires a system interrupt (int 21h), yet the only system interrupt I'm seeing is the program termination call after the keyboard interrupt.

WarrenB
  • 2,145
  • 3
  • 14
  • 18
0

Your code is ok, you just need to either run full-screen as Greg Hewgill suggested, or set up your command window to use an old raster font (like SYSTEM). Right click the title bar of the window and have a look at the Font tab.

I. J. Kennedy
  • 24,725
  • 16
  • 62
  • 87