flat assembler
Message board for the users of flat assembler.

Index > OS Construction > IMG file with int 0x10h and AH=09h

Author
Thread Post new topic Reply to topic
catafest



Joined: 05 Aug 2010
Posts: 129
catafest 17 Feb 2018, 19:27
This code run with just 187 and 10 chars of 205 ascii code.
The IMG file is run with qemu command :
Code:
qemu-system-x86_64.exe run.img
WARNING: Image format was not specified for 'run.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.    

See the screenshot:
Image

What is wrong with this code !?
Code:
format binary as 'img'
use16  
org 7c00h 

boot: 
        cli 

        push cs
        push cs 
        pop ds 
        pop es
        mov ecx, 4
        jnz short .data

.data:

        mov dx, 0x1F0
        mov cx, 256 

        ; multiple caracters CX
        mov ah, 0x09    ; function number = 09h : Display Character
        mov al, 201     ; AL = code of character to display
        mov bh, 0
        mov bl, 03h
        mov cx,1
        int 0x10        ; call INT 10h, BIOS video service
        ; multiple caracters CX
        mov ah, 0x09    ; function number = 09h : Display Character
        mov al, 205     ; AL = code of character to display
        mov bh, 0
        mov bl, 03h
        mov cx,10
        int 0x10        ; call INT 10h, BIOS video service
        ; multiple caracters CX
        mov ah, 0x09    ; function number = 09h : Display Character
        mov al, 187     ; AL = code of character to display
        mov bh, 0
        mov bl, 03h
        mov cx,1
        int 0x10        ; call INT 10h, BIOS video service
        hlt 
        jmp $ 

times 510-($-$$) db 0
                 dw 0aa55h     
Post 17 Feb 2018, 19:27
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 18 Feb 2018, 04:32
Moved to OS Construction
Post 18 Feb 2018, 04:32
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 18 Feb 2018, 08:58
catafest wrote:
What is wrong with this code !?

What behaviour do you define as “right”?

If you want to make a pseudographic window border, then you’ve obviously used the wrong code for the first character.

Anyway, you have quite serious smells in your code. Like, say, using a conditional jump without any instructions that have impact on status flags before. And the jump does nothing anyway, since the label it references marks exactly the next instruction.

Note also that BIOS functions (except maybe some corner cases) are supposed to preserve the contents of all the registers except AX, FLAGS and those used to return some data. Buggy BIOSes are of little interest, so there’s no practical need to waste bytes for putting values into each and every register before every call.
Post 18 Feb 2018, 08:58
View user's profile Send private message Visit poster's website Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 129
catafest 18 Feb 2018, 12:11
I used in the past some assembler code. I read more about 8086 in the past, but I never used into next steps like IMG format , resident program , ...
About using a conditional jump without any instructions that have impact on status flags , then :
My example is a part of study and learning process into assembly area.
To make a gui into old style , yes can be a good idea to fulfill all issues and follow the right steps .
Also the 3 rules of assembly are not enough to learn, I try to use more instructions and formats in a fair way.
One good example is old debug issues: http://thestarman.pcministry.com/asm/mbr/AA55H.html
FLAGS !? maybe FASM make something strange is too into all assembly code !!
Post 18 Feb 2018, 12:11
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 20 Feb 2018, 05:36
catafest wrote:
FLAGS !? maybe FASM make something strange is too into all assembly code !!

I don’t get this sentence. FASM, unlike MASM/TASM, does little to no strange things. Flags are architecture specific and not asm dialect related. Maybe you should express your idea/question in other words. You can use your native language, if you wish.
Post 20 Feb 2018, 05:36
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.