flat assembler
Message board for the users of flat assembler.

Index > OS Construction > One Character prints?

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus
Hey guys,

When I compile the code from fancy in this topic, add it to the bootsector of an floppy image with BFI (Build Floppy Image), load it into Bochs, I see.. well, nothing (as in, it boots, "Booting from floppy", but the next line remains empty).

Almost the same goes for my own code, but it only shows the 'A', while I expect it to loop from 'A' on and on and on:

Code:
use16
org 0x7c00

start:
  mov ah, 0x0E
  mov bh, 0x00
  mov bl, 0x07
  mov al, 65
.nextchar:
  int 0x10
  inc al
  jmp .nextchar

times 510-($-$$) db 0
dw 0xAA55    


I kept it "simple" on purpose, so without a check if al is some value or something, just to see if this would work, and it doesn't!

This code also leaves the 'A':
Code:
use16
org 0x7c00

start:
  mov ah, 0x0E
  mov bh, 0x00
  mov bl, 0x07
  mov al, 65
  int 0x10
  mov al, 66
  int 0x10
jmp start

times 510-($-$$) db 0
dw 0xAA55    


I'm kinda in the dark here, having absolutely no clue what I am doing wrong.

TIA,
Nick


Last edited by Daedalus on 25 Feb 2008, 01:06; edited 1 time in total
Post 25 Feb 2008, 00:09
View user's profile Send private message MSN Messenger Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
HelpPC 2.10 Quick Reference Utility Copyright 1991 David Jurgens

INT 10,E - Write Text in Teletype Mode


AH = 0E
AL = ASCII character to write
BH = page number (text modes)
BL = foreground pixel color (graphics modes)


returns nothing


- cursor advances after write
- characters BEL (7), BS (Cool, LF (A), and CR (D) are
treated as control codes
- for some older BIOS (10/19/81), the BH register must point
to the currently displayed page
- on CGA adapters this function can disable the video signal while
performing the output which causes flitter.



Esc or Alt-X to exit int 10,e

you can try to make
mov al,'A'
it's simpler than decimal
Post 25 Feb 2008, 00:22
View user's profile Send private message Visit poster's website Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus
Sorry if I sound quite stupid here, but if you meant that I should press either esc or alt-x, that doesn't do anything.
Post 25 Feb 2008, 00:46
View user's profile Send private message MSN Messenger Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
you can try to make it with another sub int10
for exemple 9 or A

or write your own putchar

did youi test it with a org 100h .COM code?

it works as well on .com and on .bin for BOOT

edit:
you don't sounds so stupid, just you ask for a question that was largelly aborded and resolved in the past.
but, this is the place to ask for theses things.
and we are there to reply, so, it's not stupid.

note, if you write your own boot, you SHALL write all. if not, it's not fun.

trying to make everything without BIOS.
this is FUN.


Last edited by edfed on 25 Feb 2008, 00:54; edited 1 time in total
Post 25 Feb 2008, 00:49
View user's profile Send private message Visit poster's website Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus
The second example also doesn't respond to esc or alt-x, that should print AB of course.

Writing my own doesn't really seem useful here.. int 0x10,E works, but it seems to hang after one go. Well, I suppose I can though. Let me look up where the videomemory is while this problem is solved...

I didn't test it with 100h .COM code, for I cannot run .COM files on my computer (x64).
Post 25 Feb 2008, 00:54
View user's profile Send private message MSN Messenger Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
hum
esc is not assumed to exit in this mode.

for me, it only print a non end ABABABABABABABABABABABABA string
there is no responce to escape or alt-x
support for these key shall be made by programmer.
Post 25 Feb 2008, 01:01
View user's profile Send private message Visit poster's website Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus
Ah man, that's what it's supposed to do! I really don't get why it doesn't work now, hahahaha. Well thanks for your help, good to hear my code does work, but.. just not here. If anybody has got an idea as of why (wrong configfile for Bochs? x64? Lack of luck?) please reply. I'm off to bed edfed (so you won't wait for a reply), thanks for your help.
Post 25 Feb 2008, 01:04
View user's profile Send private message MSN Messenger Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
try it in real boot.
Post 25 Feb 2008, 01:06
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 692
Location: Adelaide
sinsi
You are assuming that the video BIOS is preserving AX (and BX). A better way is
Code:
use16 
org 0x7c00 

start: 
  mov ah, 0x0E 
  mov al, 65 
.nextchar: 
  mov bh, 0x00 
  mov bl, 0x07 
  push ax
  int 0x10
  pop ax 
  inc al 
  jmp .nextchar 

times 510-($-$$) db 0 
dw 0xAA55
    

or use a byte variable to store/load/inc
Post 25 Feb 2008, 07:52
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
what about vectorial font render?
i have a problem with it.
there are true-type, open-type, type1, and others
instead to code the font, i think about coding the function to display the existing ones...
but google don't know what is the algorithm or structure
it only know it use beziers-curves and some posts on various forums...
the polution of the net is coming, the main results of google for a question are the questions themselves on forums... Sad
for exemple, now, this post will probably appear as a result in google to the question "font render".

beziers curves is not really a problem as it is a proportional, mean, interpolate algo... but there is no doc easy to find about the format of a vectorial font...

if we support the existing fonts in pure asm, an important step will be done...
Post 25 Feb 2008, 08:05
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17247
Location: In your JS exploiting you and your system
revolution
The vector fonts are bezier curves you ninny Smile They are combinations of lines and curves. So Google is giving the the proper information.

Have a look here -->How To Draw TrueType Glyph Outlines.
Post 25 Feb 2008, 08:41
View user's profile Send private message Visit poster's website Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus
Even when I preserve the values like that, it doesn't work. Like I said, I've used fancy's code from that other thread and that doesn't do anything as well. I think I'm doing something else wrong.

I first use sinsi's code, then I changed it to movs to no avail. Still the same result.
Post 25 Feb 2008, 09:32
View user's profile Send private message MSN Messenger Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 692
Location: Adelaide
sinsi
Oops, if that is all of your code then you need to set up a stack...
Code:
start:
  sub ax,ax
  mov ss,ax
  mov sp,0x7c00
  ...
    
Post 25 Feb 2008, 10:02
View user's profile Send private message Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus
No use, my code so far:

Code:
use16
org 0x7C00

start:
  xor ax, ax
  mov ds, ax
  mov sp, 0x7C00
.nextchar:
  mov ah, 0x0E 
  mov al, 65 
  mov bh, 0x00
  mov bl, 0x07 
  int 0x10
jmp .nextchar

times 510-($-$$) db 0
dw 0xAA55    


Even if it's "no use" as in it still doesn't do anything, I am learning, so thanks a lot nonetheless!
Post 25 Feb 2008, 10:24
View user's profile Send private message MSN Messenger Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 692
Location: Adelaide
sinsi
Not "mov ds,ax" but "mov ss,ax"

[edit] Just installed bochs 2.3

Using the following code and booting from it in Bochs 2.3 gives me a continually scrolling screen ("abcdef"etc.) which is what should happen.
Code:
format binary as 'img'
use16
org 0x7c00 

start:
  sub ax,ax
  mov ss,ax
  mov sp,start
  mov ah, 0x0E 
  mov bh, 0x00 
  mov bl, 0x07 
  mov al, 65 
.nextchar: 
  int 0x10 
  inc al 
  jmp .nextchar 

times 510-($-$$) db 0 
dw 0xAA55
    
Post 25 Feb 2008, 10:47
View user's profile Send private message Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus
Yeey, thanks a lot.

format binary as img doesn't do anything specific but change the extension right?

Besides that, I know that ss points to the stack segment, but what do I need to do with it? I've read osdev.org and osdever.org, but they both don't mention it on their bootloader tutorials.

I know segment registers point to some place, but not what they are used for by the computer itself, only by the programmers.

I understand that the stack segment must be at 0x0000 and the stack pointer to the first command in my program? Why is that? Or do you have a good read for that?

I even wonder why it works because I've read that the BIOS stores ISR vectors there? Won't we overwrite those or something? Please explain, and thanks for the working code.
Post 25 Feb 2008, 20:11
View user's profile Send private message MSN Messenger Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
i prefer the method to set the stack in another segment. for example, 5000h:0
when you push a value to stack, you make it:

sub sp, value.size
mov [ss:sp],value

for pop, it's the reverse:

mov value,[ss:sp]
add sp,value.size

so, with stack at 0:7c00h, you will overwrite the IVT (IVT is 1024 bytes leng.) if you make more than 15360 stages of words push. it's not realistic, but possible, and will force the PC to reboot xause int will be bad supported.

in case of separate stack segment, it's better, and let you push up to 64 Kbytes.


to remember:
push decrement the stack pointer
pop increment the SP

so, setting a separate SS:SP to 1000h:0FFFCh ( 65532 bytes)
if the last F is not a F, but a C, it's because of eventual pop, and to align the first push to a 4 bytes boundary.

ss:sp can be 1000h:0 too, and then the stack will be 64 KB leng.
Post 25 Feb 2008, 22:08
View user's profile Send private message Visit poster's website Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus
Thanks for that explanation! So if I push a value now, won't it overwrite the code @ 0000:7C00h, since it's basically a mov?
Post 25 Feb 2008, 23:47
View user's profile Send private message MSN Messenger Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
no, the push first decrement the SP
and then mov the value at SS:SP
so, if the original SP was 7C00h, then the value will be stocked at SP-value.size

you can take a pen paper and draw some diagrams to understand it better.

note:
for "all" ┬ÁP sparcr, pic, etc.. the SS:SP is always the same mechanism.
a temp stack can be used to make a dynamic data zone.
but stack is just a save of context, it is not to be param passing purposes. so, i council to avoid the straxk params if the goal is to make a multi asm code.
Post 26 Feb 2008, 00:11
View user's profile Send private message Visit poster's website Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus
Oh, I misread. Thought push incremented, pop decremented. Doesn't MingW pass all it's parameters through the stack? What's wrong with it?
Post 26 Feb 2008, 00:15
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2020, Tomasz Grysztar.

Powered by rwasa.