wszyscy myślą, że to dno. ale na dnie tak nie wieje...

A standardized procedure for dealing with messages to a dialog procedure
can also be created in the same way, except that it should return TRUE
(eax=1) if the message is processed and FALSE (eax=0) if it is not, without
calling DefWindowProc. The same coding method can be applied to hooks and
to enumerator CALLBACKS although these will vary.
jorgon@compuserve.com
http://ourworld.compuserve.com/homepages/jorgon
::/ \::::::.
:/___\:::::::.
/| \::::::::.
:| _/\:::::::::.
:| _|\ \::::::::::.
:::\_____\:::::::::::............................................THE.UNIX.WORLD
Fire Demo ported to Linux SVGAlib
by Jan Wagemakers
In APJ4 there was a little nice fire demo written in DOS assembly language.
I have ported this program to Linux assembly language. It is written in the
AT&T-syntax (GNU assembler) and makes use of SVGAlib.
My main goal of porting this program to Linux was to show that it can be
done. So, I have not optimized this program. For example, things like 'call
ioperm' can also be done by making use of int 0x80; quite possibly making use
of int 0x80 will make the program smaller. More information about int 0x80 is
available at Konstantin Boldyshev's webpage [http://lightning.voshod.com/asm].
With SVGALib you can access the screen memory directly, just like you
would write to A000:0000 in a DOS asm-program.
I like to thank 'paranoya' for his explanation about how to make use of
SVGAlib. Anyway, enough blablabla, here is the source ;-)
# fire.s : fire.asm of apj 4 ported to Linux/SVGAlib ==========================
# gcc -o fire fire.s -lvga
.globl main
.type main,@function
main:
pushl %ebp
movl %esp,%ebp
call vga_init # Init vga
pushl $5
call vga_setmode # set mode to 5 = 320x200x256
addl $4,%esp
pushl $0
call vga_setpage # Point to page 0 (There is only 1 page)
addl $4,%esp
pushl $0x3c8 # Get IOpermission, starting from 3c8h
pushl $2 # to 3c9h
pushl $1 # Turn On value
call ioperm
addl $12,%esp
pushl $0x60 # Get IOpermission, for 60h : keyboard
pushl $1
Pushl $1
call ioperm
addl $12,%esp
inb $0x60,%al # Read current value of keyboard
movb %al,key
movw $0x3c8,%dx
movw $0,%ax
outb %al,%dx
incw %dx
lus:
outb %al,%dx
outb %al,%dx
outb %al,%dx
incw %ax
jnz lus
movl graph_mem,%ebx
Mainloop:
movl $1280,%esi # mov si,1280 ;
movl $0x5d00,%ecx # mov ch,5dh ; y-pos, the less the faster demo
pushl %esi # push si
pushl %ecx # push cx
Sloop:
movb (%ebx,%esi),%al # lodsb
incl %esi #
addb (%ebx,%esi),%al # al,[si] ; pick color and
addb 320(%ebx,%esi),%al # add al,[si+320] ; pick one more and
shrb $2,%al # shr al,2
movb %al,-960(%ebx,%esi) # mov [si-960],al ; put color
loop Sloop
popl %edi # pop di
popl %ecx # pop cx
Randoml:
mulw 1(%ebx,%edi) # mul word ptr [di+1] ; 'random' routine.
incw %ax
movw %ax,(%ebx,%edi) #stosw
incl %edi
incl %edi
loop Randoml
inb $0x60,%al
cmpb key,%al
jz Mainloop
pushl $0
call exit
addl $4,%esp
movl %ebp,%esp
popl %ebp
ret
.data
key:
.byte 0
# =============================================================================
::/ \::::::.
:/___\:::::::.
/| \::::::::.
:| _/\:::::::::.
:| _|\ \::::::::::.
:::\_____\:::::::::::................................ASSEMBLY.LANGUAGE.SNIPPETS
Abs
by Chris Dragan
;Summary: Calculates absolute value of a signed integer in eax.
;Compatibility: 386+
;Notes: 9 bytes, 4 clocks (P5), destroys ecx
mov ecx, eax ; Duplicate value
shr ecx, 31 ; Fill ecx with its sign
xor eax, ecx ; Do 'not eax' if negative
sub eax, ecx ; Do 'inc eax' if negative
; For comparison, the standard way (2-8 clocks on P5 and 1-17 on P6):
; or eax, eax
; js @@1
; neg eax
;@@1:
Min
by Chris Dragan
;Summary: eax = min (eax, ecx) (both eax and ecx unsigned)
;Compatibility: 386+
;Notes: 8 bytes, 4 clocks (P5), destroys ecx and edx
sub ecx, eax ; ecx = n2 - n1
sbb edx, edx ; edx = (n1 > n2) ? -1 : 0
and ecx, edx ; ecx = (n1 > n2) ? (n2 - n1) : 0
add eax, ecx ; eax += (n1 > n2) ? (n2 - n1) : 0
; Standard cmp/jbe/mov takes 2-8 clocks on P5 and 1-17 on P6
Max
by Chris Dragan
;Summary: eax = max (eax, ecx) (both eax and ecx unsigned)
;Compatibility: 386+
;Notes: 9 bytes, 5 clocks (P5), destroys ecx and edx
sub ecx, eax ; ecx = n2 - n1
cmc ; cf = n1 <= n2
sbb edx, edx ; edx = (n1 > n2) ? 0 : -1
and ecx, edx ; ecx = (n1 > n2) ? 0 : (n2 - n1)
add eax, ecx ; eax += (n1 > n2) ? 0 : (n2 - n1)
; Standard cmp/jae/mov takes 2-8 clocks on P5 and 1-17 on P6
OBJECT
by mammon_
;Summary: Primitive for defining dynamic objects
;Compatibility: NASM
;Notes: The basic building block for classes in NASM; part of
; an ongoing project of mine. Note that .this can be
; filled with the instance pointer, and additional
; routines such as .%1 [constructor] and .~ can be added.
%macro OBJECT 1
struc %1
.this: resd 1
%endmacro
%macro END_OBJECT 0
endstruc
%endmacro
;_Sample:________________________________________________________________
;OBJECT MSGBOX
; .hWnd: resd 1
; .lpText: resd 1
; .lpCapt: resd 1
; .uInt: resd 1
; .show: resd 1
;END_OBJECT
;;MyMBox is a pointer to a location in memory or in an istruc; its members
;;are filled in an init routine ['new'] with "show" being "DD _show"
;_show: ;MSGBOX class display routine
; push dword [MyMbox + MSGBOX.uInt]
; push dword [MyMbox + MSGBOX.lpCapt]
; push dword [MyMbox + MSGBOX.lpText]
; push dword [MyMbox + MSGBOX.hWnd]
; call MessageBoxA
; ret
;..start:
; call [MyMbox + MSGBOX.show]
; ret
::/ \::::::.
:/___\:::::::.
/| \::::::::.
:| _/\:::::::::.
:| _|\ \::::::::::.
:::\_____\:::::::::::...........................................ISSUE.CHALLENGE
Binary-to-ASCII
by Jan Verhoeven
The Challenge
-------------
Write a routine to convert the value of a bit to ASCII in under 10 bytes, with
no conditional jumps.
The Solution
------------
Load the number into the AX register and shift through the bits. If a bit is
cleared [0], you want to print a "0" character; if a bit is set [1], you want
to print a "1".
Prime the BL register with the ASCII character "0"; if the next bit in AX is
set, carry will be set after the SHL and BL will thus be incremented to an
ASCII "1". The key, as you will see, is the ADC [AddWithCarry] instruction:
L0: B330 MOV BL,30 ; try with al = ZERO
D1E0 SHL AX,1 ; ... but if bit = set, ...
80D300 ADC BL,00 ; ... make it a ONE,
7 bytes all told; with a loop and mov instruction for storing each value in
BL to the location of your choice, you will have a full-fledged binary-to-
ascii converter in a handful of bytes.
::/ \::::::.
:/___\:::::::.
/| \::::::::.
:| _/\:::::::::.
:| _|\ \::::::::::.
:::\_____\:::::::::::.......................................................FIN