フレームバッファのテストプログラム試... 投稿者:maeha 投稿日:2004/12/08(Wed) 14:50 No.319 | |
|
こんにちは
お蔭様で Framebuffer Device の使用できることがわかりました。 そこで、テストのため、色の data を表示する program を 作りましたので、ご覧ください。
この program は Framebuffer の端から順に、そこに色の data を increment しながら書き込み画面上部に表示します。
vga=317 で実行できます。vga=311 でするには、stosw命令の直前の mov ecx,32 を mov ecx,30 に変更により可能です。 vga=317 では色は 16bit あり、一度に全部は書ききれませんので、 順次、自動にスクロールし、一順で終了します。 私のマシンでは40秒ほどかかります。vga=311 では25秒ほどです。
この source program は fasm の表記ですので、他の assembler には 少し修正が必要になります。
以上よろしくお願いいたします。
maeha
; - - - - - - - - - - - - - - - - - - - - - - - ; Color Rectangles in Framebuffer Device ; vga = 317 single Rectangle scrole
format ELF executable
entry start
section readable writeable
fb db '/dev/fb0',0 mm_start dd 0 mm_length dd 524288 ; 64 * 4 scanLine * 2048 mm_port dd 3 ; PROT_READ|PROT_WRITE mm_flags dd 1 ; MAP_SHARED mm_fd dd ? mm_offset dd 0 ScreenAddr dd ? ColorPos dd ? ColorBegin dw ?
start: lea ebx,[fb] mov ecx,2 ; O_RDWR mov eax,5 ; open int 80h mov [mm_fd],eax
lea ebx,[mm_start] mov eax,90 ; mmap int 80h mov [ScreenAddr],eax
; - - - - Color Rectangle - - - - test eax,80000000h jnz error mov [ColorBegin],0h ;color starts from 0h cld LoopRectangle: mov bx,[ColorBegin] add [ColorBegin],32 ;Advance color to next Rectangle mov edi,[ScreenAddr] mov ecx,64 ;number of Element Line in Rectangle LineElement: push ecx mov ecx,4 ;number of Scan Line in Element LineScan: mov ax,bx ;repeat same color in Element push ecx mov ecx,32 ;Number of Element in Scan line Element: push ecx ; mov ecx,20 ;Scan Pixels in Element for vga=311 mov ecx,32 ;Scan Pixels in Element for vga=317 rep stosw ;store pixels into scanning line inc ax ;next color pop ecx ;Number of Element remaining loop Element ;right most Element? pop ecx ;end of scan line? loop LineScan pop ecx ;end of Rectangle? mov bx,ax ;reserve color for next Element Line loop LineElement cmp [ColorBegin],0 ;looped all color? jnz LoopRectangle error: mov eax,91 ;munmap mov ebx,[ScreenAddr] mov ecx,[mm_length] int 80h
mov eax,6 ; close mov ebx,[mm_fd] int 80h
mov eax, 1 xor ebx, ebx int 0x80 ; exit ; - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| Re: フレームバッファのテストプログラ... jun - 2004/12/09(Thu) 20:04 No.320 | |
|
|
vga=317 で2-3秒でした。 fasmはよく分からなかったので nasm 用に書き直して実行しました。 この掲示板ではインデントができない(スペースが潰れる)ので 全角空白を使っています。
; - - - - - - - - - - - - - - - - - - - - - - - ; Color Rectangles in Framebuffer Device ; vga = 317 single Rectangle scrole
;format ELF executable
;entry start
section .text
global _start
_start:
lea ebx, [fb] mov ecx, 2 ; O_RDWR mov eax, 5 ; open int 0x80 mov [mm_fd], eax
lea ebx, [mm_start] mov eax, 90 ; mmap int 0x80 mov dword [ScreenAddr], eax
; - - - - Color Rectangle - - - - test eax, 0x80000000 jnz error mov word [ColorBegin], 0 ;color starts from 0h cld LoopRectangle: mov bx, [ColorBegin] add word [ColorBegin], 32 ;Advance color to next Rectangle mov edi,[ScreenAddr] mov ecx,64 ;number of Element Line in Rectangle LineElement: push ecx mov ecx, 4 ;number of Scan Line in Element
LineScan: mov ax, bx ;repeat same color in Element push ecx mov ecx, 32 ;Number of Element in Scan line
Element: push ecx ; mov ecx,20 ;Scan Pixels in Element for vga=311 mov ecx, 32 ;Scan Pixels in Element for vga=317 rep stosw ;store pixels into scanning line inc ax ;next color pop ecx ;Number of Element remaining loop Element ;right most Element? pop ecx ;end of scan line? loop LineScan pop ecx ;end of Rectangle? mov bx, ax ;reserve color for next Element Line loop LineElement cmp word [ColorBegin], 0 ;looped all color? jnz LoopRectangle error: mov eax, 91 ;munmap mov ebx, [ScreenAddr] mov ecx, [mm_length] int 0x80
mov eax, 6 ; close mov ebx, [mm_fd] int 0x80
mov eax, 1 xor ebx, ebx int 0x80 ; exit
section .data fb db "/dev/fb0", 0 mm_start dd 0 mm_length dd 524288 ; 64 * 4 scanLine * 2048 mm_port dd 3 ; PROT_READ|PROT_WRITE mm_flags dd 1 ; MAP_SHARED mm_fd dd 0 mm_offset dd 0 ScreenAddr dd 0 ColorPos dd 0 ColorBegin dw 0 ; - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| Re: フレームバッファのテストプログラ... maeha - 2004/12/10(Fri) 20:35 No.321 | |
|
|
全く驚きましたね、vga=317 で2-3秒とは、驚異的スピードですね。 それで青から赤まで全部 32枚スクロールしているのでしょうね。 この速度の相異はどこからくるのでしょう。 単に Hardware の相異によるものでしょうか。 私のは Pentium 4 1.8GHz Ram=128MB ですが、 Ramの容量に関係するものでしょうか。 またもや、頭の中に????印がでてしまいました。
ところで、全角空白とは、どうやって使いますか?
maeha
|
| Re: フレームバッファのテストプログラ... jun - 2004/12/11(Sat) 02:12 No.322 | |
|
|
確認のために、少し簡単にしてみました。 同じ色で1024*768の全画面を塗りつぶすことを10回繰り返し、 これを1000回色を変えて繰り返します。計10000回の全画面を塗りつぶし になります。
実行すると、 ~$ time ./fbtest real 0m15.664s user 0m15.664s sys 0m0.000s のように15秒程度でした。これを実行した環境は Pentium4 2.25GHz チップは845GEで、デスクトップとしては古いものです。 メモリは512MBですが、関係あるとは思えません。 15秒は予想より速いのですが、Pentium4は1命令を1ns以下で実行するため 「こんなものかな」とも思います。
;----------------------------- ; fbtest ;----------------------------- section .text
global _start
_start: mov ebx, fb mov ecx, 2 ; O_RDWR mov eax, 5 ; open int 0x80 mov [mm_fd], eax mov ebx, mm_start mov eax, 90 ; mmap int 0x80 mov [ScreenAddr], eax cld mov edx, 1000 Loop10: add ax, 0x0821 mov ebx, 10 LoopScreen: mov edi, [ScreenAddr] mov ecx, 1024*768 rep stosw ;store pixels into screen dec ebx jnz LoopScreen dec edx jnz Loop10
mov eax, 91 ;munmap mov ebx, [ScreenAddr] mov ecx, [mm_length] int 0x80
mov eax, 6 ; close mov ebx, [mm_fd] int 0x80
mov eax, 1 xor ebx, ebx int 0x80 ; exit
section .data fb db "/dev/fb0", 0 mm_start dd 0 mm_length dd 1572864 ; 768 * 2048 mm_port dd 3 ; PROT_READ|PROT_WRITE mm_flags dd 1 ; MAP_SHARED mm_fd dd 0 mm_offset dd 0 ScreenAddr dd 0 ;-----------------------------
単にスペース2つを全角空白に置換しているだけです。 |
| Re: フレームバッファのテストプログラ... maeha - 2004/12/13(Mon) 14:19 No.323 | |
|
|
Junさんのfbtest(全面10000枚)をやりましたら、10分かかりました。 私のスクロール式を全面式にするには mov ecx,4 ;number of Scan Line in Element を3倍の mov ecx,12 にします。 スクロール式のときは2048枚を描いています。 全面スクロールにすると、私の場合2分かかりました。
このたびは、マシンにより、かくも速度に差があることを理解しました。
maeha
|
|