Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 12 Apr 2006
Offline Last Active Mar 04 2015 09:34 PM

Posts I've Made

In Topic: MASM Assembly bug [SOLVED]

07 February 2015 - 06:20 PM


Not that hot on MASM coding but it looks like there need to a be and end of string character after the age. Looks like $ is used to mark the end of a string. With no end marker after age it will keep on printing the next thing in memory. What if you create a variable with a single $ after the age.

age db ?
endofline db '$'


you must be a wizard biggrin.png  thank you!

In Topic: C++ & SDL Help Needed!

07 February 2015 - 12:44 PM

No idea (I don't have a mac). Have you tried this? http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php


Yes I tried this tutorial :/

In Topic: C++ & SDL Help Needed!

07 February 2015 - 12:42 PM

I am not in my home right now and here I dont have a MAC.... ( I develop using C++ and SDL2 in my macbook at home )....
So, may you share your configuration screen with us? (The configuration screen, in XCODE where you link the libraries? )
I can check it tonight, when I come home and share my configs...

Everytime I try to run the console app template for SDL2 it crashes and gives me a window saying it ended unexpectedly.
I have attached a pic of that window as well as the build phase screen cap

In Topic: MASM Assembly Help!

07 February 2015 - 12:26 PM


Another thing, I've been kind of thinking of the int 21h call as a 'do it' operation. Is this the right way to think about the "int 21h" call? I tried googling int 21h to find a clear explination of that operation, but had no luck :/ If so, how does the "int 21h" call know which lines I want it to "do"?

INT is sort of like a CALL instruction that does some extra stuff. Kind of like how CALL is just a JMP that does extra stuff.

Somewhere in memory, there is an "interrupt vector table" (IVT for short) which is just an array of function pointers. The INT instruction looks up an entry in that table (using the numeric operand you gave to INT as the index) and then uses the address in the array to call a function.

Back when I used DOS in real mode, the IVT was at memory address zero.

"But who creates the IVT", you ask? The BIOS does, at system startup. You can read more about the gory details here:


After INT has found the address and called the function, the function itself works just like what Buckeye posted.



Sweet, thank you for the explination and link! gonna read that in a few mins biggrin.png



Looks like most of the important bits were covered, but there are some loose ends.

The first and very important bit is that all of those commands are dead or dying. While Ralph Brown's Interrupt List is useful for hardware developers and for developers in the 1980s and 1990s, today in 2015 it is mostly historical.

That said, if you are doing DOS based programming, that old masm assembler can be a fun way to learn lower level programming. You'll probably need a DOS emulator like dosbox if you want to have most of the old functionality, but I'll assume you've got all that.

Interrupt 21h is the DOS general functionality interrupt.

Hundreds of pieces of DOS functionality were tied into that interrupt. Exactly what functionality took place depends on the contents of the AH register.

For example:
01h reads a byte from standard input
02h writes a byte to standard output
09h writes a string to standard output (as you discovered)
2Ah reads the system date
2Bh sets the system date
2Ch reads the system time
2Dh sets the system time
39h creates a disk directory
3Ah deletes a disk directory
3Ch creates a file
3Dh opens a file
3Eh closes a file

And on and on.

There are/were interrupts for every piece of functionality provided by the OS and the hardware. Graphics hardware was generally accessed through interrupt 10h and various ports and memory blocks. The mouse was generally accessed through interrupt 33h.

One of my favorite little bad hacks was to open edlin (a very simple line editor) jump to position 100 (where command executables start) and enter the two bytes cd19. Then save it as a .com file. CD is the bytecode for 'interrupt', I'll let you look up interrupt 19h. Then I'd call the command in their autoexec.bat file, before any TSRs were loaded. Fun times were had by many, but not all.

Anyway, back on track.

Almost every interrupt will expect some values loaded into registers. The system would document those. Back in the 1980s many computers came with manuals that documented all or most of the overriden interrupts and their parameters. Devices like printers and modems would also include details of their command codes and escape sequences. It was cryptic to most people, but necessary for developers and system administrators in order to customize the software and hardware to run together.

You as the programmer could then look up the functionality you needed. If you wanted to change the graphics mode you would set the right parameters to indicate the graphics mode, then call interrupt 10h, and when it returned it would load the status codes. If you wanted to read the mouse coordinates you would set the right parameters to indicate what you wanted to read, and when it returned it would load the mouse position.

As others have pointed out, this is rather dated. Most of these are virtualized on modern hardware, you have your own little sandbox you are playing in and a private little interrupt table is established for your application. Many of the old 16-bit function DOS calls no longer work as Microsoft declared years ago "DOS is dead." But in practice it is not as dead as they had hoped.


Awesome explination and thanks for a short desc of some other interrupt calls, I think I am begining to understand things better! About your cd19 and autoexec.bat hack, did that allow you to control their ROM utilities? haha I looked it up and I read a little about the bootstrap loader.


About this being 16 bit DOS and to learn 32 bit instead, I wish I could because it sounds like its more useful in this day and age, but the reason I am learning it is because it's a required class I need to go toward my CS degree. However my instructor said this semester might be the last semester he teaches this course. All we have done is a "Hello World" application so far, so I am just trying to learn some stuff on my own.


Once again I want to thank everyone for your explinations and help! cool.png

In Topic: MASM Assembly Help!

06 February 2015 - 07:37 PM


how does the "int 21h" call know which lines I want it to "do"?


int 21h, when AH==9, uses the address in DX as a pointer to a string.


As Nypryren mentions, think of int 21h as:

if( AH==9 ) print the characters at the address in DX (until a stop character '$' is encountered)

I don't know if you're familiar with a switch() statement, but int 21h is sort of like:

; int 21h
switch( AH )
   case 9:
      get the address stored in register DX;
      print the characters at DX, DX+1, etc., until '$' is encountered
   case (another value):
      do something else
   case ...


Thank you so much that was an awesome explination! Im coming from Java and C/C++ so that was perfect