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: 1421
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: 1158
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: 1158
Location: Russia
macomics 24 May 2025, 20:26
I have it working on qemu.


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

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


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

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


Description:
Filesize: 60.48 KB
Viewed: 285 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: 1421
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
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.