0

I have a very short assembly TASM program:

IDEAL
MODEL small
STACK 100h
DATASEG

;creating all the messages
opening_message db 10, 'This is an encryption program.', 10, 'This program allows you to encrypt a message into giberish,', 10, 'send it to a friend, who can then decrypt it back into text$'


CODESEG
start:
    mov ax, @data
    mov ds, ax
; --------------------------
; Your code here
; --------------------------
    ;We clear the screen of dosbox
    mov ax, 13h
    int 10h
    mov ax, 2
    int 10h

    ;print opening message
    lea dx, [opening_message]
    mov ah, 9
    int 21h
exit:
    mov ax, 4c00h
    int 21h
END start

When I try to run the program in DOSBOX-X, the lastest version, 64bit, The newline character (10) in the string is printed at a huge offset. See image

problem Can anyone help? Thanks P.S. The program is working fine in vanilla dosbox

Itai Elidan
  • 272
  • 9
  • 27

1 Answers1

4

DOSBox adheres to the DOS rule of requiring both carriage return (13) and linefeed (10) to output a newline.

Your code only uses the linefeed and thus the text only drops a line.

opening_message db 13, 10, 'This is an encryption program.'
  db 13, 10, 'This program allows you to encrypt a message into giberish,'
  db 13, 10, 'send it to a friend, who can then decrypt it back into text', 13, 10, '$'

;We clear the screen of dosbox
mov ax, 13h
int 10h
mov ax, 2
int 10h

Why do you first set the graphics screen 13h (320x200) and then the text screen 02h (80x25) ? Note that usually the 80x25 text screen is setup from using mode number 03h.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
  • Thanks, I am new to assembly and this helped! – Itai Elidan May 24 '21 at 06:13
  • I am settings the screen to graphic and then back to text to clear the screen. Is there a better way? – Itai Elidan May 25 '21 at 10:23
  • 1
    @ItaiElidan To clear the screen we just **set the video mode once**. Since DOSBox by default operates in screen mode 03h (text 80x25), all you need is `mov ax, 0003h` `int 10h`. (First setting the graphic screen is not doing anything useful, it's a redundant operation) – Sep Roland May 25 '21 at 12:31