flat assembler
Message board for the users of flat assembler.

Index > DOS > I have difficulty printing a character into 0xB800

Author
Thread Post new topic Reply to topic
Rosnic



Joined: 14 May 2025
Posts: 2
Rosnic 15 May 2025, 22:05
use16
msg db 'ABCD'

mov ax,0xB800
mov es,ax

mov si,msg
mov al,byte [si]

mov [es:di],al
mov [es:di+1],0x07
Post 15 May 2025, 22:05
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1426
Location: Piraeus, Greece
Picnic 15 May 2025, 23:42
Hi Rosnic,

Compile it with FASM and run it in DOSBox.
Code:

    org 0x100 

    mov ax, 0xB800 
    mov es, ax

    mov di, 0x67C        ; Position on screen (row 10, column 30)

    mov si, string     
    mov bx, colors       ; pointer to the color attributes
    mov cx, 6            ; number of characters

    next_char:
    lodsb                ; load byte from ds:si into al, increment si
    mov ah, [bx]         ; load attribute byte into ah
    stosw                ; store ax at es:di, increment di by 2
    inc bx               ; move to next attribute
    loop next_char       ; repeat for all characters

    ret

    string db 'Rosnic'
    colors db 0x0C, 0x0A, 0x0E, 0x09, 0x0B, 0x0F  ; red, green, yellow, blue, cyan, white
    


I always have the impression that 16-bit assembly is the most fun. Smile
Post 15 May 2025, 23:42
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1159
Location: Russia
macomics 16 May 2025, 06:57
Code:
    org 0x100 

    mov ax, 0xB800 
    mov es, ax

    mov di, 2 * (9 * 80 + 30) ; 0x67C        ; Position on screen (row 10, column 30)

    mov si, string     
    mov bx, colors       ; pointer to the color attributes
    mov cx, 6            ; number of characters

    next_char:
    lodsb                ; load byte from ds:si into al, increment si
    mov ah, [bx]         ; load attribute byte into ah
    stosw                ; store ax at es:di, increment di by 2
    inc bx               ; move to next attribute
    loop next_char       ; repeat for all characters

    mov di, 2 * (10 * 80 + 25)
    mov bx, 2 * (11 * 80 + 10)
    mov si, colored_string

    another_loop:
    mov al, [si]
    mov ah, [si + 2]
    stosw
    lodsw
    mov [es:bx], ax
    add bx, 2
    cmp byte [si], 0
    jnz another_loop

    int 0x20 ; ret

    string db 'Rosnic'
    colors db 0x0C, 0x0A, 0x0E, 0x09, 0x0B, 0x0F  ; red, green, yellow, blue, cyan, white

    colored_string db 'R', 0x0C, 'o', 0x0A, 's', 0x0E, 'n', 0x09, 'i', 0x0B, 'c', 0x0F, 0    


Last edited by macomics on 24 May 2025, 20:13; edited 1 time in total
Post 16 May 2025, 06:57
View user's profile Send private message Reply with quote
Rosnic



Joined: 14 May 2025
Posts: 2
Rosnic 24 May 2025, 20:09
I'm compiling in pure binary code and using the VirtualBox simulator but it doesn't seem to work.
Post 24 May 2025, 20:09
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1159
Location: Russia
macomics 24 May 2025, 20:26
I have it working on qemu.


Description:
Filesize: 67.85 KB
Viewed: 511 Time(s)

Снимок экрана_20250525_002414.png


Description:
Filesize: 65.9 KB
Viewed: 511 Time(s)

Снимок экрана_20250525_002454.png


Description:
Filesize: 60.48 KB
Viewed: 511 Time(s)

Снимок экрана_20250525_002521.png


Post 24 May 2025, 20:26
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1426
Location: Piraeus, Greece
Picnic 24 May 2025, 23:16
I successfully ran it on DosBOX and Emu8086 (screenshot).

Image
Post 24 May 2025, 23:16
View user's profile Send private message Visit poster's website Reply with quote
bitdog2u



Joined: 31 Jan 2023
Posts: 10
Location: Ketchikan, Alaska
bitdog2u 04 Jun 2025, 15:38
Picnic has the right DOS code. For video mode 3 & maybe Vmode 1 also?
if it doesn't work, it's not the code that needs changing.
At the garbage dump pick up an old DOS computer. Second hand stores ?
I run DOS 6.2 on a 3.2 ghz North Wood CPU
the fastest 100% DOS cpu made, that was common and reliable.
Great with Redneck Rampage Rides Again running Uranus Attacks group.
Straight DOS is a great environment for creating any .ASM to run on any OS.
Then a JUMP DRIVE gets it to a computer running on an OS on CD so the HARD DRIVE won't be corrupted and you can test it. Well that is one way to do it.
Altering the code to work in a bad environment, means that the only people who can use your code have to be using the same bad environment. = useless.
You can print a whole colored screen with this proc.

MSG: DW 160*10 ;Line 10 Vmode 3
DB 12,"Hello World",0

align 2
PRNstr: ;CALL with, DS:SI = message adr & ES = $B800 screen SEG
LODSW
MOV DI,AX ; Screen address
LODSB
MOV AH,AL ; Color
LODSB
@@: STOSW
LODSB

CMP AL,10
JZ PRNstr ; LF= Get another Line & put it some where

CMP AL,0
JNZ @B ; Print Lines until NUL=0

RET
Post 04 Jun 2025, 15:38
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.