Delphi
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Iron Speed
Go Back   Tutorialized ForumsDesktop ProgrammingDelphi

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 26th, 2005, 04:07 PM
eternallove29 eternallove29 is offline
Junior Member
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 2 eternallove29 New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
Assembly Programming

Can somebody fix this code written in Assembly Language?
It works for BMP files.....i.e. it first checks for the valid BMP file n then load it..

Please have a look.

.model small
.stack 100h
.186
.code

PUBLIC ShowBMP

ShowBMP proc
pusha
call OpenInputFile
jc FileErr
mov bx,ax
call ReadHeader
jc InvalidBMP
call ReadPal
push es
call InitVid
call SendPal
call LoadBMP
call CloseFile
pop es
jmp ProcDone

FileErr:
mov ah,9
mov dx,offset msgFileErr
int 21h
jmp ProcDone

InvalidBMP:
mov ah,9
mov dx,offset msgInvBMP
int 21h

ProcDone:
popa
ret
ShowBMP endp

CheckValid proc
clc
mov si,offset Header
mov di,offset BMPStart
mov cx,2

CVloop:
mov al,[si]
mov dl,[di]
cmp al,dl
jne NotValid
inc si
inc di
loop CVloop
jmp CVdone

NotValid:
stc

CVdone:
ret
CheckValid endp

GetBMPInfo proc
mov ax,header[0ah]
sub ax,54
shr ax,2
mov PalSize,ax
mov ax,header[12h]
mov BMPWidth,ax
mov ax,header[16h]
mov BMPHeight,ax
ret
GetBMPInfo endp

InitVid proc
mov ax,13h
int 10h
push 0a00h
pop es
ret
InitVid endp

LoadBMP proc
mov cx,BMPHeight

ShowLoop:
push cx
mov di,cx
shl cx,6
shl di,8
add di,cx

mov ah,3fh
mov cx,BMPWidth
mov dx,offset Scrline
int 21h

cld
mov cx,BMPWidth
mov si,offset Scrline
rep movsb

pop cx
loop Showloop
ret
LoadBMP endp

ReadHeader proc
mov ah,3fh
mov cx,54
mov dx,offset Header
int 21h

call CheckValid
jc RHdone
call GetBMPinfo

RHdone:
ret
ReadHeader endp

ReadPal proc
mov ah,3fh
mov cx,PalSize
shl cx,2

mov dx,offset palbuff
int 21h
ret
ReadPal endp

OpenInputFile proc
mov dx,offset My_file
mov ah,4Dh
mov al,1
int 21h

mov handle,ax
OpenInputFile endp


CloseFile proc
mov bx,Handle
mov ah,3Eh
int 21h

CloseFile endp

SendPal proc
mov si,offset palBuff
mov cx,PalSize
mov dx,3c8h
mov al,0
out dx,al
inc dx

sndLoop:
mov al,[si+2]
shr al,2

out dx,al
mov al,[si+1]
shr al,2
out dx,al
mov al,[si]
shr al,2
out dx,al

add si,4

loop sndLoop
ret
SendPal endp

.data
My_file db 'c:\new.bmp',0
Handle dw ?
Header label word
HeadBuff db 54 dup('H')
palBuff db 1024 dup('P')
Scrline db 320 dup(0)
BMPStart db 'BM'
PalSize dw ?
BMPHeight dw ?
BMPWidth dw ?
msgInvBMP db "Not a valid BMP file.",7,0dh,0ah,24
msgFileErr db "Error opening file.",7,0dh,0ah,24
end

If anyone can help in fixing the errors then it'd be highly appreciated.

Thanks

~eternallove29

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingDelphi > Assembly Programming


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway