Search code examples
assemblytasmdosbox

DOSBOX-X Bug: newline is offset to the right


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


Solution

  • 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.