assemblyx86-16tasmdosbox

Strange symbols appear when I print memory with 'Int 21h/AH=09h"


I'm using TASM, TLINK and TD (debugger) in DOSBox.

I've recently tried programming a simple ASM 8086 program that is suppose to print the value at address 0100h. When I print the result I get output that resembles:

enter image description here

My code is:

.MODEL SMALL
.STACK
.DATA
.CODE
.STARTUP

MOV SI,0100H
MOV WORD PTR[SI],31
MOV DX,0
MOV AH,09H
MOV DX,[SI]
INT 21H

MOV AH,4CH
INT 21H

END

Solution

  • Invoking the 21H interrupt with AH set to 09H, will print the $ terminated string in register DX. In your case DX contains 31H, which will point (I assume) to garbage, that's why you're getting random symbols printed.

    Create the string you want to print inside your data section, and make the DX register point to it, before invoking the print syscall.