2

I set the video mode to AL=00h , it's a text mode with 40x25 char , 16 colors , and 8 pages.

40x25 should mean printing 1000 character will make the screen full of the character, but to my surprise it doesn't , i need to print 1024 character to make the screen full of the character .

But why ? can someone explain this to me ? why does 40x25 char screen contains 1024 character ?

Edit : After posting this question , i do some testing and found something interesting , to fill first line with character , i need to print 40 times , to fill 2nd line , i need to print 81 times , to fill 3rd line , i need to print 122 time , to fill 4th line , i need to print 163 time , why do i need to print extra 1 time for every new line ?

Edit 2 : i counted the character on screen manually like a mad man , there is exactly 1000 character , but i printed 1024 times , where did the other 24 character go ?!?1

here are my code

ORG 100h  
mov ah,00h   ; ah=00 mode
mov al,00   ; text mode. 40x25. 16 colors.8 pages
int 10h    
mov ah,09h   ; ah=09 mode
mov bh,00   ; page 0
mov al,'A'  ; character to display
mov cx,1024 ; print the character 1024 times
mov bl,1fh  ; high-intensity white on blue
int 10h
RET

1000 character

1024 character

  • 6
    [Ralf Brown](http://www.ctyme.com/intr/rb-0099.htm) says "Replication count in CX may produce an unpredictable result in graphics modes if it is greater than the number of positions remaining in the current row." So this may simply be a "don't do that". If you want to know exactly why it happens, you may have to read the code of emu8086's BIOS. – Nate Eldredge Jun 16 '21 at 17:20
  • `rep stosw` to actual video RAM should work consistently. – Peter Cordes Jun 16 '21 at 17:30
  • @NateEldredge ah okay , i guess i will just stick to int 21h for printing text , thank you – i'm ashamed with what i asked Jun 16 '21 at 18:29
  • You can use `ah =-09h int 10h` for all rows except the last and you'll get the expected outcome. It's only buggy for the last row. I'm speaking from personal experience here. Also, just remember that the printing cursor position after the `int` is the same as it was before. – puppydrum64 Jan 06 '23 at 13:55

0 Answers0