16-bit assembly?

Posts 115 of 17 · Page 1 of 2
16-bit assembly?
Hi.

I've run into yet another problem involving assembly, this time it's in 16 bit.

So, I was getting into 16 bit assembly, you know COM files and interrupts.

I was trying to use interrupt 10H ( Video ) to write a string to the screen, ( AH being 13H ). Here's what I have so far.

[PHP]
.286

.model tiny

.data
org 100h
Message db 'Hello',0

.code

main:

jmp short start
nop

start:

mov al,0 ;Mode
xor bh,bh ;Page
mov bl,0Ch ;Text attribute - Color
mov cl,5 ;Length of string
mov dh,1 ;Row - x
mov dl,0 ;Column - y

push ds ;Push ds onto stack
pop es ;Pop into es

lea bp,[Message] ;Move Message into bp register

mov ah,13h
int 10h

int 20h

ret

end main
[/PHP]

It almost works, I'm going to guess the problem is:
[PHP]
lea bp,[Message]
[/PHP]

It prints random characters to the screen, it's prints in the right row and column, the right color, no compiling errors, it just prints random text and I have no idea what the problem is.

Also, I'm not too sure about that:
[PHP]
push ds
pop es
[/PHP]

I found it after googling a lot, nothing seems to work. This is how I came up with this code. This site: Bios Interrupts

If you scroll down and find Interrupt 10H ( video ) and AH 13H. It says:
Code:
ES:BP points to the string.
I don't understand how you do that in assembly. >_>

I'd be grateful to who ever could give me an explanation or link me to a good site.

Thanks.
Sorry no one can help you bud. =/

Why are you trying to do this anyway? can windows even run 16 bit anymore?
Damnit Why, you got my hopes up when I saw that someone replied. ;(

Yes it Windows can still run 16 bit applications. I'm not sure about using interrupts though, since Windows runs in protected mode and doesn't allow direct access with hardware. Once again, I'm not sure. That's what this thread is for. >_>
Yeh I know you were expecting: "David good news! I have learned about 16 bit programming and interrupts seemingly overnight and can solve any problem you have!" =P

Just read an old DOS tutorial on assembly then. There's a ton of 16bit asm tuts cuz no one has made any new ones... ;l
Quote Originally Posted by why06 View Post
Yeh I know you were expecting: "David good news! I have learned about 16 bit programming and interrupts seemingly overnight and can solve any problem you have!" =P

Just read an old DOS tutorial on assembly then. There's a ton of 16bit asm tuts cuz no one has made any new ones... ;l
There are, I had the idea to print each character 1 one a time. I want to make use of this though, it's there for a reason. Surprisingly, there aren't actually that many 16 bit tutorials that go passed the pushing,popping and mov'ing... Or atleast, I couldn't find any.

Anyways, I'm going to sleep. Good night.

Edit: Actually I was expecting BA. ;D
Quote Originally Posted by Void View Post
There are, I had the idea to print each character 1 one a time. I want to make use of this though, it's there for a reason. Surprisingly, there aren't actually that many 16 bit tutorials that go passed the pushing,popping and mov'ing... Or atleast, I couldn't find any.

Anyways, I'm going to sleep. Good night.

Edit: Actually I was expecting BA. ;D
Oh if only BA was here. With five dollars and and a 16bit Amiga BA could take over the world.
16bit doesn't run on 64bit machine btw, so idk how long this proggie might be good for running on anything.
~
read a book on 16bit asm or something....
Quote Originally Posted by Arhk View Post
16bit doesn't run on 64bit machine btw, so idk how long this proggie might be good for running on anything.
~
read a book on 16bit asm or something....
I've been reading about 16 bit assembly, most people use the 'write character' interrupt and write each character individually. I only found one 'write string' snippet and it doesn't seem to be working. =\

Also, I forgot to add to my original post. Is there a difference between a software/hardware interrupt and a BIOS interrupt?
you'd have to initialize your data segment before you can use it. put something like:
Code:
 mov ax, @data
 mov ds, ax
at the beginning of your code.
It seems that the TINY model does not allow segment address references. Is this true, or am I doing something wrong here? =\

Edit: I forgot to mention I'm trying to assemble .COM files. I don't know if there's any other way if you don't use the TINY model.
ack that's what I get for skimming over;
yes Tiny = Com Files & CS == DS basically.

you could try this:
mov xx,OFFSET cs:Message
(so below in the first sample try:
mov bp,OFFSET cs:Text )


Or just make a .exe with a memory model of small

Found this sample that seems to do what you want (using small memory model, thus exe)
Code:
.model small
.stack
.code

mov ax,@data 		; set up ds as the segment for data
mov es,ax 		; put this in es

mov bp,OFFSET Text 	; ES:BP points to message
mov ah,13h 		; function 13 - write string
mov al,01h 		; attrib in bl,move cursor
xor bh,bh 		; video page 0
mov bl,5 		; attribute - magenta
mov cx,17 		; length of string
mov dh,5 		; row to put string
mov dl,5 		; column to put string
int 10h 		; call BIOS service

mov ax,4C00h 		; return to DOS
int 21h

.data

Text DB "This is some text"

end
Or, another one:
Code:
            mov al, 1
            mov bh, 0
            mov bl, 0011_1011b
            mov cx, msg1end - offset msg1 ; calculate message size. 
            mov dl, 10
            mov dh, 7

            push cs
            pop es

            mov bp, offset msg1
            mov ah, 13h
            int 10h

            jmp msg1end

            msg1 db " hello, world! "

            msg1end:
Oh my gosh. BA, I love you.

That is all.
Lookie there, and that was even without the five dollars. xD

much obliged BA.
Quote Originally Posted by why06 View Post
Lookie there, and that was even without the five dollars. xD

much obliged BA.
BA is a legend. He deserves more than just a couple of thanks.
I'd thank but I don't usually thank things I can't follow.
~
give me like a month xD
Posts 115 of 17 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?