Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
About
Team
Rules
Stats
Status
Sitemap
Chat
Downloads
Forum
News
Our Projects
Major Community Projects
Recent Posts
Unread Posts
Replies
Tools
SourceCoder3
Other Things...
Omnimaga Radio
TI-83 Plus ASM File Unsquisher
Z80 Conversion Tools
IES TI File Editor
Free RAM areas
Comprehensive Getkeyr table
URL Shortener
Online Axe Tilemap Editor
Help
Contact Us
Change Request
Report Issue/Bug
Team
Articles
Members
View the memberlist
Search For Members
Buddies
Login
Register
Omnimaga
»
Forum
»
Calculator Community
»
TI Calculators
»
ASM
»
GAME: Optimize this! (z80 assembly)
« previous
next »
Print
Pages: [
1
]
2
Go Down
Author
Topic: GAME: Optimize this! (z80 assembly) (Read 12605 times)
0 Members and 1 Guest are viewing this topic.
Halifax
LV9
Veteran (Next: 1337)
Posts: 1334
Rating: +2/-1
GAME: Optimize this! (z80 assembly)
«
on:
August 27, 2007, 04:11:00 am »
Basically everything can be optimized about this code. Post your optimized code with timings and bytes and we will see who has the most optimized code in the end!
c1-->
CODE
ec1
xor a
ld hl,0
ld d,e
ld l,h
mainloop:
ld a,$FF
out (1),a
ld a,$FE
out (1),a
nop
nop
in a,(1)
cp '1'
call z,is_1
cp '2'
call z,is_2
cp '3'
call z,is_3
cp '4'
call z,is_4
cp '5'
call z,is_5
cp 0
jp z,mainloop
jp mainloop
is_1:
ld de,no_label1
ld b,5
call convert_num
ret
is_2:
ld de,no_label2
ld b,5
call convert_num
ret
is_3:
ld de,no_label3
ld b,5
call convert_num
ret
is_4:
ld de,no_label4
ld b,5
call convert_num
ret
is_5:
ld de,no_label5
ld b,5
call convert_num
ret
convert_num:
ld hl,0
conv_loop:
ld a,(de)
inc de
cp '1'
ccf
adc hl,hl
djnz conv_loop
ret
c2
ec2
Logged
There are 10 types of people in this world-- those that can read binary, and those that can't.
DJ Omnimaga
Clacualters are teh gr33t
CoT Emeritus
LV15
Omnimagician (Next: --)
Posts: 55943
Rating: +3154/-232
CodeWalrus founder & retired Omnimaga founder
GAME: Optimize this! (z80 assembly)
«
Reply #1 on:
August 27, 2007, 06:37:00 am »
let's hope CoBB from MC won't find this topic because he's instant winner by default then O_O
Logged
Halifax
LV9
Veteran (Next: 1337)
Posts: 1334
Rating: +2/-1
GAME: Optimize this! (z80 assembly)
«
Reply #2 on:
August 27, 2007, 01:15:00 pm »
These optimizations are all easily findable, whether it is something I have said before, or something recently posted on MaxCoderz.
Logged
There are 10 types of people in this world-- those that can read binary, and those that can't.
DJ Omnimaga
Clacualters are teh gr33t
CoT Emeritus
LV15
Omnimagician (Next: --)
Posts: 55943
Rating: +3154/-232
CodeWalrus founder & retired Omnimaga founder
GAME: Optimize this! (z80 assembly)
«
Reply #3 on:
August 27, 2007, 01:36:00 pm »
ok, now if i knew assembly. I hope an assembly coder like iambian or jon passes by
Logged
JonimusPrime
LV6
Super Member (Next: 500)
Posts: 389
Rating: +25/-5
GAME: Optimize this! (z80 assembly)
«
Reply #4 on:
August 27, 2007, 03:44:00 pm »
I fail at asm but even I can find Optimizations in that (too bad I'm too lazy to go through and type them).
Logged
"Always code as if the person who will maintain your code is a maniac serial killer that knows where you live" -Unknown
"If you've done something right no one will know that you've done anything at all" -Futurama
"Have a nice day, or not, the choice is yours." Tom Steiner
Fallen Ghost
Guest
GAME: Optimize this! (z80 assembly)
«
Reply #5 on:
August 27, 2007, 04:15:00 pm »
Using TASM syntax, not including timings or bytes (sorry, too lazy). But what the hell is that code doing? I'm assuming that you are looking for only 1 arrow at a time being pressed. I'm also assuming you want to optimize for speed, but not enough to uber-speed loop decompression. And I also noticed you kinda made a mistake by either not letting us know what the equates were for the 'x' (where x is the number) or by treating them as litteral and not including cpl. I'm assuming that 'x' is an equate of value less than 128 (you can't get more than that from a cpl'ed port 1 anyway).
Did you want me to throw that in or just say it is a code used on a hardware with other port settings (so let the port thing away and giving us the equates)? I'm assuming no. I'm also assuming that the no_labelX are not equally spaced/not in order in memory.
c1-->
CODE
ec1
ret
c2
ec2
And it may not be very speedy though, but I'm kinda too tired to do better.
Please answer my questions and you'll get better code, as now it wouldn't work for arrow keypress detection.
But as you see, the code, as you put it, has no output other than adding, and then does nothing with it, so for overall usefulness, then my code is the best (can't really beat 10T / 1Byte).
Logged
DJ Omnimaga
Clacualters are teh gr33t
CoT Emeritus
LV15
Omnimagician (Next: --)
Posts: 55943
Rating: +3154/-232
CodeWalrus founder & retired Omnimaga founder
GAME: Optimize this! (z80 assembly)
«
Reply #6 on:
August 27, 2007, 04:39:00 pm »
idk what he meant to do really, iirc it was meant to be a piece of code like the basic code samples in the 83+ manual, which does nothing, since its just some kind of excercise anyway
Logged
Fallen Ghost
Guest
GAME: Optimize this! (z80 assembly)
«
Reply #7 on:
August 27, 2007, 04:42:00 pm »
Yeah, but I need to know if he made errors in his above code or only optimize it. And also if the 'X' things are equates (reread my code now)
Logged
DJ Omnimaga
Clacualters are teh gr33t
CoT Emeritus
LV15
Omnimagician (Next: --)
Posts: 55943
Rating: +3154/-232
CodeWalrus founder & retired Omnimaga founder
GAME: Optimize this! (z80 assembly)
«
Reply #8 on:
August 27, 2007, 05:03:00 pm »
I'm trying to ask him on IRC atm but he seems idle hopefully he'll check this topic again soon
Logged
Halifax
LV9
Veteran (Next: 1337)
Posts: 1334
Rating: +2/-1
GAME: Optimize this! (z80 assembly)
«
Reply #9 on:
August 27, 2007, 05:07:00 pm »
Just optimize it. It is just an exercise. Do high-level and algorithm optimization. Nothing on how memory is accessed.'
It is all pretty simple although I am sure that there is one optimization people may not find.
EDIT: Actually there are 2 optimizations that I think won't be found.
Logged
There are 10 types of people in this world-- those that can read binary, and those that can't.
Jon
LV5
Advanced (Next: 300)
Posts: 278
Rating: +0/-0
GAME: Optimize this! (z80 assembly)
«
Reply #10 on:
August 27, 2007, 08:14:00 pm »
c1-->
CODE
ec1
mainloop:
ld a,$FE
out (1),a
ld a,(de);7 t-state delay
in a,(1)
cp '1'
call z,is_1
cp '2'
call z,is_2
cp '3'
call z,is_3
cp '4'
call z,is_4
cp '5'
call z,is_5
jr mainloop
is_1:
ld de,no_label1
ld b,5
jr convert_num
is_2:
ld de,no_label2
ld b,5
jr convert_num
is_3:
ld de,no_label3
ld b,5
jr convert_num
is_4:
ld de,no_label4
ld b,5
jr convert_num
is_5:
ld de,no_label5
ld b,5
jr convert_num
convert_num:
ld hl,0
conv_loop:
ld a,(de)
inc de
cp '1'
ccf
adc hl,hl
djnz conv_loop
ret
c2
ec2
74 bytes
453 t-states if B=5
I don't see what the hell the point of this routine is....
Next time i'd put in something that actually has a function. I was really confused
Firstly, $FE is the keygroup for the 4 arrow keys, not the number keys. Secondly, the hex value returned by port 1 is not '1', etc. but rather hex values based on the Direct Input table ($FE,$FD,$FB,$BF,$7F)
Logged
Halifax
LV9
Veteran (Next: 1337)
Posts: 1334
Rating: +2/-1
GAME: Optimize this! (z80 assembly)
«
Reply #11 on:
August 27, 2007, 09:59:00 pm »
Haha yeah, maybe I should but there are a lot of algorithm wise things that you missed to improve the code.
Logged
There are 10 types of people in this world-- those that can read binary, and those that can't.
Fallen Ghost
Guest
GAME: Optimize this! (z80 assembly)
«
Reply #12 on:
August 27, 2007, 11:37:00 pm »
bytes: 48
timing if B=5: 315 T states, 255 T if you unroll the conv_loop
c1-->
CODE
ec1mainloop2:
ld a,$FF
mainloop:
out (1),a
dec a
out (1),a
ld d,0
in a,(1)
dec a
jr c,mainloop
add a,a
ld e,a
ld hl,table-(('1')*2)+2
add hl,de
ld a,(hl)
inc hl
ld l,(hl)
ld h,a
ld b,5
ld a,$FF
conv_loop:
ld c,(hl)
inc hl
dec c
adc a,a
Logged
Halifax
LV9
Veteran (Next: 1337)
Posts: 1334
Rating: +2/-1
GAME: Optimize this! (z80 assembly)
«
Reply #13 on:
August 28, 2007, 01:13:00 am »
Very good. Still conv_loop is not optimized.
Logged
There are 10 types of people in this world-- those that can read binary, and those that can't.
Fallen Ghost
Guest
GAME: Optimize this! (z80 assembly)
«
Reply #14 on:
August 28, 2007, 02:31:00 pm »
Well, registers have been changed and comparison too. Now unless you unroll it up (which I don't assume you think as a good idea), I don't see what we can do. That said, I don't know what exactly you can throw away in doing a more limited task (something only you knows).
[Edit]Just took out 17 clocks by using the cpl instead of the ccf
Oh, and by most optimized, you talk about speed only or bytes too?
[Edit #2]Yeah, well, look at it now
Logged
Print
Pages: [
1
]
2
Go Up
« previous
next »
Omnimaga
»
Forum
»
Calculator Community
»
TI Calculators
»
ASM
»
GAME: Optimize this! (z80 assembly)