flat assembler
Message board for the users of flat assembler.

Index > Main > Modified Compos

Goto page Previous  1, 2, 3

Do you think it is a fair thing to optimize someone's compo, and then add your credit?
Yes, if you don't change the docs
4%
 4%  [ 1 ]
Yes, if you don't change the docs, and respect the author ( no words like shit, sux ... )
52%
 52%  [ 11 ]
Yes, but only if you don't post it anywhere (internal use)
14%
 14%  [ 3 ]
No, it is not fair to add your name to someone's compo, even if it whould fit in after the optimization
9%
 9%  [ 2 ]
No, compo's are made by the author and are as is, and no subject to change, they're the way they meant to be implemented
19%
 19%  [ 4 ]
Total Votes : 21

Author
Thread Post new topic Reply to topic
asmdemon



Joined: 18 Jan 2004
Posts: 97
Location: Virginia Beach, VA
asmdemon
Quote:
Sorry i have to tell you
but $60 is a byte port,
hence , you will lose 1 bytes. @ dec al


but "in ax,60" and "dec ax" does work on my machine and compiles in under 32 bytes. i have not seen however, anywhere it is said that you can "only" input a byte instead of a word from the port, but i have noticed that it fills 'ah' with different values based on what key was pressed.

0x301C is the value of ax when enter is pressed using 'in ax,0x60'.
0x001C is the value of ax when enter is pressed using 'in al, 0x60'.

in doing this, i saved 1 byte, fitting into the constraints of the original competion requirements.

ralf brown int list d, port a, section on port 60h:

Quote:
PORT 0060-006F - KEYBOARD CONTROLLER 804x (8041, 8042) (or PPI (8255) on PC,XT)
Note: XT uses ports 60h-63h, AT uses ports 60h-64h

0060 RW KB controller data port or keyboard input buffer (ISA, EISA)
should only be read from after status port bit0 = 1
should only be written to if status port bit1 = 0
0060 R- KeyBoard or KB controller data output buffer (via PPI on XT)
PC: input from port A of 8255, if bit7 in 61h set (see #P063)
get scancodes, special codes (in PC: with bit7 in 61h cleared)
(see #P057)

_________________
It is better to be on the right side of the devil than in his path.
Post 11 Oct 2004, 00:01
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
yeah, i see you have saved 1 byte, but it doesn't exit anymore, because on my computer, ah will not be 0 after in ax,$60
if you look at the first page, that was my problem with snow32.

but if you want to be polite, you should check status port bit0, and read if keyboard ready, i used to do it in case of files not size optimized.
so take note that just reading or writing ports may hang the device or system.

MATRIX
Post 11 Oct 2004, 00:18
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
Code:
; they are the same in size, but the right side won't exit on esc if ah<>0
; 5 bytes (7 with int 20h)
; i will not take any responsibility for any hardware damages
; this code can cause
; i recommend using the right side with dec al, however its all right if ah=0
; MATRIX
org 256

mainloop:
in ax,$5f    ; in al,$60
sahf         ; dec ax
jnc mainloop ; jnc mainloop

int 20h
    


MATRIX
Post 11 Oct 2004, 02:09
View user's profile Send private message Visit poster's website Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 340
Location: Trollhättan, Sweden
bubach
i think i'll hire you to optimize my os when it's done.. Smile


Last edited by bubach on 13 Feb 2012, 14:09; edited 1 time in total
Post 12 Oct 2004, 07:32
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Matrix, you could exercise on Menuet kernel source Very Happy
I've found something like:
Code:
 ;imul ebx, 640*4          ; (y+Ywin)*BytesPerScanLine
      lea ebx,[5*ebx]      ;Madis opt.
      shl ebx,9

 ;shl eax,2                ; (x+Xwin)*BytesPerPixel
 ;add eax,ebx              ;Madis opt.
     lea eax,[eax*4+ebx]
    

time to time I found code where speed AND code were optimized.
The main purpose for me is to get it faster. If the code is smaller
as a side-effect, that's fine Wink
Code:
Hey, check this out:
;    mov  esi,[0xfe00]      ; 'it is safe..'

;    shr  esi,1
;    sub  esi,220     ;????
;    add  esi,27      ;The most suprising!
;    shl  esi,16
;    mov  eax,esi
;    add  eax,[shutdownpos]
;    add  eax,37
    mov esi,[0FE00h]        ;Madis opt.
    sub esi,2*(220-27)      ;...
    shl esi,15
    mov eax,[shutdownpos]
    lea eax,[eax+esi+37]    ;...      
    

I know that shutdown code is only executed once and the speed nor size is not the most important issues, but as I had nothing to do one day, I tried optimizing these codes Smile
the last code optimized 38 vs. 29 bytes
8 vs. 5 codelines meaning 3clock gain on the average of 1 op/cycle
on a PIII my code performs 3clocks and leaves µ-op spare
when the original code performs 5-6clocks on a PIII
Post 12 Oct 2004, 09:50
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
Smile
YEAH THAT'S NICE
if i have nothing to do i will take a look.
in many cases you can optimize algorithms, loops, and in addition you can try smaller/faster opcodes.

MATRIX
Post 12 Oct 2004, 14:03
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
linking to 256 byte TETRIS
@ heap
Post 02 Dec 2004, 01:34
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.