4coder
Source Code Search Engine:
   
CPU: 0%
Mem: 7%
Exec: 0,013ms
Source codes: New | Assembler | ASP | C, C++ | C# | Delphi | Java | JavaScript | Perl | PHP | Python | Ruby | SQL | Visual Basic

Assembler Source Code: BMP Viewer (File: bmpviewer.asm)

<< Back to source: BMP Viewer





File name:

 bmpviewer.asm - ( View Plain Text ) ( Download File )

File date:

 2007-04-20 20:36:24

Size:

 299 lines, 4865 bytes

Syntax highlighting:

 Assembler

 

Lines:Source code:

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.

#make_COM#

CSEG segment
assume CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG
ORG 100h

BEGIN:
mov ax,es
mov fileES,ax

CALL OpenImage

mov cx,30 
mov dx,offset bmpHANDLE 
CALL ReadImage

mov cx,bmpHND_Size 
sub cx,30 
mov dx,offset Buffer 
CALL ReadImage

mov ax,bmpHND_SIZE
lea di,inf2
CALL NumToStr
mov ax,bmpWIDTH
lea di,inf4
CALL NumToStr
mov ax,bmpHEIGHT
lea di,inf6
CALL NumToStr
mov ax,bmpRGB_SIZE
lea di,inf8
CALL NumToStr
mov ax,bmpCntFRAME
lea di,inf91
CALL NumToStr
LEA DX,inf1
MOV AH,9
INT 21h    ;Write File Information
MOV ah,0
INT 16h

mov ax,4f02h
mov bx,11Bh
int 10h

mov ah,0
int 16h

mov ax,bmpHEIGHT
mov yi,ax

mov ax,bmpWIDTH
add ax,bmpWIDTH
add ax,bmpWIDTH
mov bmpCntReadByte,ax

@PC:
dec yi 
mov xi,0
lea dx,Buffer 
mov BuffPos,dx  
mov cx,bmpCntReadByte 
  mov ax,fileES
  mov es,ax
    CALL ReadImage 
  mov ax,0A000h
  mov es,ax
@PaintCicle:
mov di,BuffPos
lea si,colB
mov ax,ds:[di]
mov ds:[si],ax
mov al,ds:[di+2]
mov ds:[si+2],al
add di,3
mov BuffPos,di
        ;call RGBtoGREY  ;BLACK & WHITE Color
        ;call InvertRGB  ;Invertion Color
        call PaintPixel  ;Paint Pixel
inc xi 
mov ax,bmpWIDTH
cmp xi,ax
jne @PaintCicle
cmp yi,0
jne @PC

  mov ax,fileES
  mov es,ax   
call CloseImage ;Close opened image-BMP

mov ah,0
int 16h
mov ax,3  ;Set Text Video Mode
xor bx,bx
int 10h
mov dx,offset About
mov ah,9
int 21h
mov ah,0
int 16h
MOV AH, 4Ch
INT 21h

;================DECLARE PROCEDURE========================
OpenImage PROC
mov ax,3D00h
mov dx,offset File_name
int 21h
;jc Error_file
mov Handle,ax
RET
OpenImage ENDP

CloseImage PROC
mov ah,3Eh
mov bx,Handle
int 21h
RET
CloseImage ENDP

ReadImage PROC
mov bx,Handle
mov ah,3Fh
int 21h
RET
ReadImage ENDP

PaintPixel PROC
     mov si,curWin
     mov ax,yi
     mov bx,ax
          mov cl,4
          sal ax,cl
          sub ax,bx
     mov dx,xi
     mov bx,dx
     add bx,dx
     add bx,dx
          add al,bh
          adc ah,0
     xor dh,dh
     mov dl,ah
     mov bh,al
     mov curWin,dx
     mov di,bx
     xor bx,bx
cmp dx,si
JE @myNop
          mov ax,4F05h
          int 10h
     @myNop:
cmp di,65534
JE   @metod_2
JNBE @metod_1
          mov al,colB  ;Set Pixel Color
          mov es:[di],al ;PAINT PIXEL
          mov al,colG
          mov ah,colR
          mov es:[di+1],ax
     RET ;exit proc
     @metod_1:
          mov al,colB  ;Set Pixel Color}
          mov es:[di],al ;PAINT PIXEL}
          inc dx ;curWin=curWin+1}
               mov ax,4F05h
               int 10h
          mov al,colG
          mov ah,colR
          mov es:[0],ax ;PAINT PIXEL}
     RET ;exit proc
     @metod_2:
          mov al,colB  ;Set Pixel Color}
          mov ah,colG
          mov es:[di],ax  ;PAINT PIXEL}
          inc dx ;curWin=curWin+1}
               mov ax,4F05h
               int 10h
          mov al,colR
          mov es:[0],al  ;PAINT PIXEL}
     RET ;exit proc
PaintPixel ENDP

NumToStr PROC ; MOV AX,<number> | LEA DI,<StringOperand>
xor dx,dx
cmp ax,1000
jb @NXT1 ;if ax < 1000 then goto
mov bl,48
mov [di+1],bl
mov [di+2],bl
mov [di+3],bl
mov bx,1000
div bx
 add al,48
mov [di],al
mov ax,dx
xor dx,dx
@NXT1:
cmp ax,100
jb @NXT2 ;if ax < 100 then goto
mov bl,48
mov [di+2],bl
mov [di+3],bl
mov bx,100
div bx
 add al,48
mov [di+1],al
mov al,dl
xor ah,ah
@NXT2:
cmp ax,10
jb @NXT3 ;if ax < 100 then goto
mov bl,48
mov [di+3],bl
mov bl,10
div bl
 add al,48
mov [di+2],al
mov al,ah
@NXT3:
 add al,48
mov [di+3],al
RET
NumToStr ENDP

RGBtoGREY PROC
xor dx,dx
xor ah,ah
mov al,colR
mov dl,colG
add ax,dx
mov dl,colB
add ax,dx
mov bl,3
div bl
mov colB,al
mov colG,al
mov colR,al
RET
RGBtoGREY ENDP

InvertRGB PROC
mov al,255
sub al,colB
mov colB,al
mov al,255
sub al,colG
mov colG,al
mov al,255
sub al,colR
mov colR,al
RET
InvertRGB ENDP

bmpCntReadByte dw 0
BuffPos dw 0
curWin dw 0
fileES dw 0
cntByte dw 0
colB db 255
colG db 255
colR db 255
xi dw 0
yi dw 0
Handle dw 0
About db 'Create by Karelin Alexander!$'
	inf1 db ' BMP HEADER SIZE -> '
	inf2 db 0,0,0,0
	inf22 db ' byte',13,10
	inf3 db ' BMP WIDTH       -> '
	inf4 db 0,0,0,0
	inf44 db ' px',13,10
	inf5 db ' BMP HEIGHT      -> '
	inf6 db 0,0,0,0
	inf66 db ' px',13,10
	inf7 db ' BMP COLOR SIZE  -> '
	inf8 db 0,0,0,0
	inf88 db ' bit',13,10
	inf9 db ' BMP FRAME COUNT -> '
	inf91 db 0,0,0,0
	inf99 db 13,10
	inf12 db ' Press <Enter> for load image! File - '
file_name db 'pic.bmp',0,'$'
bmpHANDLE dw 0
bmpReserve db 8 dup(0)
bmpHND_Size dw 0
bmpRes2 dw 0
bmpINF_Size dw 0
bmpRes3 dw 0
bmpWIDTH dw 0
bmpRes4 dw 0
bmpHEIGHT dw 0
bmpRes5 dw 0
bmpCntFRAME dw 0
bmpRGB_SIZE dw 0
Buffer db 0
buffer2 db 0
CSEG ends
end Begin


 
Recommended: Coloring Pages for Kids - Demotywatory - Learning for Kids - Vampire Diaries
Contact - Upload - Ranking - RSSAll trademarks used are properties of their respective owners.
The source codes are owned by the poster. We aren't responsible for their content.
Copyright © 2012-2015 4Coder.org