Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.os.development > #9419
| From | "Benjamin David Lunt" <zfysz@fysnet.net> |
|---|---|
| Newsgroups | alt.os.development |
| Subject | Re: THANKS FOR INFO & SUGGESTIONS |
| Date | 2016-04-09 21:28 -0700 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <neckpi$1f0k$1@gioia.aioe.org> (permalink) |
| References | <ndqsef$9r8$1@dont-email.me> <20160403173650.55074eb8@_> <ne0b78$m2g$1@dont-email.me> <ne1541$17fa$1@gioia.aioe.org> <nebqrl$8it$1@dont-email.me> |
"bilsch" <king621@comcast.net> wrote in message
news:nebqrl$8it$1@dont-email.me...
> OK, I've got it how I want it. Your suggestions about saving space were
> good, as I ran out of room at one point. Code is more efficient and
> compact now. The program is listed below if anybody is interested.
> Thanks. Bill S.
Glad to help. I'll make a few more suggestions.
> <code>
> org 0x7c00
> bits 16
> SECTION .text
>
> xor ax,ax ; set up segments
> mov ds, ax
> mov es, ax
> mov ss, ax ; setup stack
> mov sp, 0x7c00 ; stack grows downwards from 0x7c00
>
> mov si,msg41
> call print_string
> mov bx,0x55aa
> mov dl,0x80
; As Mike noted, DL is passed to your code.
mov [saved_dl],dl
; and comment out the line you used above,
; being sure not to modify DL beforehand.
> mov ah,0x41
> int 0x13
> push cx
> cmp ah,0x10 ;ver 1.x
> jne ver20
> mov word[bsiz],0x1a
> ver20:
> cmp ah,0x20 ;ver 2.0
> jne ver21
> mov word[bsiz],0x1e
> ver21:
> cmp ah,0x21 ;ver 2.1
> jne ver30
> mov word[bsiz],0x1e
> ver30:
> cmp ah,0x30 ;ver 3.0
> jne ckbsiz
> mov word[bsiz],0x42
> ckbsiz:
> cmp word[bsiz],0
> jne ah41
> mov si,noext ;no int 13h ext
> call print_string
> jmp nend ;w/o bsiz we're going nowhere
> ah41:
Depending on how you look at it, the above
code is missing some 'jmp's or in the case
I show below, has way too many :-)
First, in the code above, even after you put the
correct value into [bsiz], you still cmp ah for
each additional check. No problem, except that
it is slower code and larger code. How about
something like this:
mov word[bsiz],0x1a
cmp ah,0x10 ;ver 1.x
je ah41
mov word[bsiz],0x1e
cmp ah,0x20 ;ver 2.0
je ah41
; mov word[bsiz],0x1e
cmp ah,0x21 ;ver 2.1
je ah41
mov word[bsiz],0x42
cmp ah,0x30 ;ver 3.0
je ah41
mov si,noext ;no int 13h ext
call print_string
jmp nend ;w/o bsiz we're going nowhere
ah41:
Less code, fewer jumps.
> mov si,ahmsg41 ;ah =
> call print_string
> mov bx,i2xt
> mov cx,2 ;cx = # of digits to translate
> call b2xa
> api:
> mov si,apimsg ;'api = '
> call print_string
> pop ax ;this is pushed cx
> xlat ;table result in al, bx already points i2xt
> mov ah,0xe
> int 0x10 ;write
Also as Mike said, bh should be zero before the
interrupt call above.
> ah48:
> mov si, msg48 ;display BIOS call
> call print_string
> clc ;clear CF
> mov si,sxbuf ;bufr for BIOS to fill
> mov di,word[bsiz]
> mov [sxbuf],di ;bufr size for BIOS call
> mov ah,0x48
> mov dl,0x80 ;bit 7 = hd
> int 0x13
> jc cf1
> mov si, cfzro
> call print_string
> jmp ah48m
> cf1:
> mov si, cfone
> call print_string
> ah48m:
Again, the 'mov' instruction does not modify the
flags register, so you can do a mov before the
carry check:
mov si, cfone
jc cf1
mov si, cfzro
cf1:
call print_string
; less code, fewer jumps
> mov si,ahmsg48 ;'ah='
> call print_string
> mov cx,2 ;cx = # of digits to translate
> call b2xa
> dsxinfo:
> mov si, sxmsg ;'hex # sectors = '
> call print_string
> mov di,0x16 ;start w/bytes 0x16 & 0x17
> get4digit:
> mov cx,4 ;cx counts 4 nibbles/word
> mov ax,[sxbuf+di]
> outdigit:
> rol ax,4 ;put hi hex digit on right
> push ax ;save rol'd ax
> and al,0x0f ;digit in al, is index into i2xt
> xlat ;table result in al
> mov ah,0xe
xor bh,bh
> int 0x10 ;write
> pop ax ;rol'd version of ax
> dec cx
> jnz outdigit ;4 digit loop - 1 nibble/loop
> dec di
> dec di
> cmp di,0xe ;end w/bytes 0x10 & 0x11
> jnz get4digit ;get next 4 hex digits
> nend:
> mov si, tstamp ;date & time (manual)
> call print_string
> jmp $ ;jmp here infinite loop
>
> msg41 db 0xd,0xa,'int 13h, ah=41h', 0xd, 0xa, 0
> msg48 db 0xd,0xa,'int 13h, ah=48h', 0xd, 0xa, 0
> ahmsg41 db 'ah = ', 0
> noext db ' no int 13h ext', 0
> apimsg db ' api = ', 0
> cfzro db 'CF=0=success.', 0xd, 0xa, 0
> cfone db 'CF=1=failed.', 0xd, 0xa, 0
> ahmsg48 db 'ah>0 is an error code. ah = ', 0
> sxmsg db 0xd, 0xa ,'# of sectors = ', 0
> tstamp db 0xd, 0xa ,'4/08/16 7:00 am', 0
> i2xt db '0123456789ABCDEF'
> bsiz dw 0
> sxbuf times 0x42 db 0 ;bufr for BIOS to fill
> ; ===============================================================
> ; calls start here
> ; ===============================================================
>
> print_string:
> push ax ;preserve ax
> .lup:
> lodsb ; grab a byte from si
> or al, al ; logical or al by itself
> jz .done ; if the result is zero, get out
> mov ah, 0xe
> int 0x10 ; otherwise, print out the character!
> jmp .lup
> .done:
> pop ax ;preserve ax
> ret
>
> b2xa: ;ax has data, cx has # nibs to translate
> rol ax,4 ;put hi hex digit on right
> push ax ;rol'd version
> and al,0x0f ;digit in al, is index into i2xt
> xlat ;table result in al, bx already points i2xt
> mov ah,0xe
> int 0x10 ;write
> pop ax
> dec cx
> jnz b2xa
> ret
>
> times 510-($-$$) db 0
> dw 0xAA55
> </code>
I didn't go through it with as much detail, but it does
look better. Good job. Isn't learning fun :-)
Ben
Back to alt.os.development | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: How to use BIOS int 13h ah=48h ? Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-04-03 17:36 -0400
Re: How to use BIOS int 13h ah=48h ? bilsch <king621@comcast.net> - 2016-04-05 05:34 -0700
Re: How to use BIOS int 13h ah=48h ? "Benjamin David Lunt" <zfysz@fysnet.net> - 2016-04-05 12:53 -0700
THANKS FOR INFO & SUGGESTIONS bilsch <king621@comcast.net> - 2016-04-09 14:09 -0700
Re: THANKS FOR INFO & SUGGESTIONS "Mike Gonta" <mikegonta@gmail.com> - 2016-04-09 18:42 -0400
Re: THANKS FOR INFO & SUGGESTIONS Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-04-10 04:02 -0400
Re: THANKS FOR INFO & SUGGESTIONS "Alexei A. Frounze" <alexfrunews@gmail.com> - 2016-04-10 01:31 -0700
Re: THANKS FOR INFO & SUGGESTIONS "Benjamin David Lunt" <zfysz@fysnet.net> - 2016-04-09 21:28 -0700
Re: THANKS FOR INFO & SUGGESTIONS bilsch <king621@comcast.net> - 2016-04-13 17:30 -0700
Re: THANKS FOR INFO & SUGGESTIONS Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-04-13 22:09 -0400
Re: THANKS FOR INFO & SUGGESTIONS "wolfgang kern" <nowhere@never.at> - 2016-04-10 11:02 +0200
Re: THANKS FOR INFO & SUGGESTIONS "wolfgang kern" <nowhere@never.at> - 2016-04-10 13:31 +0200
Re: How to use BIOS int 13h ah=48h ? Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-04-06 00:10 -0400
csiph-web