OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 7:57 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: help
PostPosted: Fri Mar 15, 2002 12:00 am 
Has anyone got a peice of code (in nasm) that (using lodsb and no stack or anything like that) reads a byte and displays it?

(dont want to use any int21 stuff)

Thanx


Top
  
 
 Post subject: RE:help
PostPosted: Fri Mar 15, 2002 12:00 am 
>On 2002-03-15 16:13:47, Sum Dude wrote:
>Has anyone got a peice of code (in nasm) that (using lodsb and no stack or anything like that) reads a byte and displays it?

i got it! if you mean to display the byte as it is...

>(dont want to use any int21 stuff)

you copy the string, whatever you want to print pointed with si, with lodsb to al and then put 0x07 (for normal format) in ah, and then mov [es:di],ax for es:di=>0xb800:(offset within 1 page on the screen) or es:di=>0xb000:(offset) if you have monochrome CRT. Do place the string, set conditions such as or al,al, then jz .done, like a while(...){} loop.

You can view a copy of my bootsector (that's where i'm testing my I/O functions w/o even BIOS), I've messed it up completely (but have some good functions written), so I'm writing a new one starting from scratch again thus I have no copies of it on the internet...but here is a sneak peak:

;; sprintf(char *string, int offset)

;; usage:
;; -----
;; mov byte ax,0 ; some kind of offset
;; push ax
;; move byte ax,string1 ;pointer to string
;; push ax
;; call sprintf ; call the f(x)
;; -----
;; this one is a near call, so takes argument from
;; bp+4 as first one
;; if you plan on to use a far call the arguments
;; are loaded as bp+6
sprintf:

push bp ; saves bp

mov bp,sp ; prepares bp for arguments

pusha ; prepare stack



mov di,0xb800 ; move in the video ram

mov es,di ; set es

mov di,[bp+6] ; set di to destinated offset

mov byte si,[bp+4] ; load string to print



.begin: ; while (pre-condition) {

mov ah,0x0f ; set attribute

lodsb ; load 1 byte from string



cmp al,0x00 ; if (al == 0x00)

jz .done ; true: done



mov word [es:di],ax ; otherwise override into mem

add di,2 ; add to bytes to video counter

jmp .begin ; } // loop back

.done:

mov bp+6,di

popa

leave

ret



That's it...


Top
  
 
 Post subject: RE:help
PostPosted: Sat Mar 16, 2002 12:00 am 
Thanx alot, you've been very helpful.


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 182 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group