flat assembler
Message board for the users of flat assembler.
Index
> Main > Small random integer generator |
Author |
|
Matrix 15 Feb 2005, 14:22
i can competite with this
Code: org 256 call set320x200x256 call initrandomz mainloop: mov ecx,320 call randomz3 mov bx,ax mov ecx,200 call randomz3 mov cx,ax push ecx mov ecx,256 call randomz3 pop ecx call putpixel320x200x256 ; al=color bx=x cx=y push eax call bkeycheck cmp al,27 pop eax jnz mainloop call set80x25t int 20h initrandomz: ; modifies edx, eax rdtsc ret randomz3: ; Z3 ecx=range transparent push ebx ; number returned is: 0 <= n < ecx push edx mov ebx,eax rdtsc mov dx,cx mov cl,al xor cl,ah ror ch,4 xor bl,ch and cx,$f rol bx,cl btc bx,cx xor bx,ax ror eax,16 xor bx,ax ror eax,16 mov cl,al xor cl,ah ror ch,4 xor bl,ch and cx,$f ror bx,cl btc bx,cx mov cl,bl .minorloop: rol eax,cl and cx,$f btc ax,cx loopw .minorloop mov cl,bh .majorloop: ror eax,cl and cl,$f btc ax,cx loopw .majorloop mov cx,dx mul ecx mov eax,edx pop edx pop ebx ret putpixel320x200x256: ; al=color, bx=x, cx=y push es push $A000 pop es mov di,cx ; y shl cx,2 add di,cx ; 5y shl di,6 ; 320y add di,bx stosb pop es ret bkeycheck: ;returns: AH = BIOS scan code AL = ASCII character note: enhanced mov ah,0x11 ;Return: ZF set if no keystroke available, ZF clear if keystroke available int 0x16 ;only checks buffer without removing key ret set320x200x256: mov ax,$13 int $10 ret set80x25t: mov ax,$03 int $10 ret |
|||
15 Feb 2005, 14:22 |
|
asmdemon 15 Feb 2005, 15:40
well, check this out... 29 bytes without the grayscale pallet, 40 if you want grayscale...
Code: $=0x0100 use16 ;320*200*256 mov al, 0x13 int 0x10 ;setup es les cx, [bx] ;set grayscale ;xor ax, ax ;mov dx, 0x03c9 ;setcolor: ;out dx, al ;out dx, al ;out dx, al ;inc ax ;jnz setcolor next: in al, 0x40 stosb shl ax, 8 in al, 0x40 imul ax, 133 mov cx, ax pausenow: loop pausenow mov ah, 1 int 0x16 jz next ret |
|||
15 Feb 2005, 15:40 |
|
Matrix 15 Feb 2005, 15:55
well its small ...
|
|||
15 Feb 2005, 15:55 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.