Hi,
I v got a tough challenge to solve please help me find its solution.
Have code but no corresponding higher language code.
Code displays 8 top records made by any users in a particular game, i have to modify it in such a way that it prints 10 records.
each record prints 3 initial chars of user taking 3 bytes followed by high score made as an integer with 4 bytes, total memory i can have is 70 bytes.
modify in such a way that i use same 70 bytes to print 10 records instead of 8 records.
code-
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $4, %esp
call initializeRecords
call printRecords
call getCurrentPlayer
call updateRecords
call printRecords
addl $4, %esp
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.size main, .-main
.globl initializeRecords
.type initializeRecords, @function
initializeRecords:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $0, -4(%ebp)
jmp .L4
.L5:
movl -4(%ebp), %edx
movl -4(%ebp), %eax
addl %eax, %eax
addl $65, %eax
movb %al, topRecords(,%edx,8)
movl -4(%ebp), %edx
movl -4(%ebp), %eax
addl %eax, %eax
addl $66, %eax
movb %al, topRecords+1(,%edx,8)
movl -4(%ebp), %edx
movl -4(%ebp), %eax
addl %eax, %eax
addl $67, %eax
movb %al, topRecords+2(,%edx,8)
movl -4(%ebp), %ecx
movl -4(%ebp), %eax
leal (%eax,%eax), %edx
movl $100, %eax
subl %edx, %eax
movl %eax, topRecords+4(,%ecx,8)
addl $1, -4(%ebp)
.L4:
cmpl $7, -4(%ebp)
jle .L5
leave
ret
.size initializeRecords, .-initializeRecords
.section .rodata
.LC0:
.string "%c%c%c %d\n"
.text
.globl printRecords
.type printRecords, @function
printRecords:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $36, %esp
movl $10, (%esp)
call putchar
movl $0, -8(%ebp)
jmp .L9
.L10:
movl -8(%ebp), %eax
movl topRecords+4(,%eax,8), %edx
movl -8(%ebp), %eax
movzbl topRecords+2(,%eax,8), %eax
movsbl %al,%ecx
movl -8(%ebp), %eax
movzbl topRecords+1(,%eax,8), %eax
movsbl %al,%ebx
movl -8(%ebp), %eax
movzbl topRecords(,%eax,8), %eax
movsbl %al,%eax
movl %edx, 16(%esp)
movl %ecx, 12(%esp)
movl %ebx, 8(%esp)
movl %eax, 4(%esp)
movl $.LC0, (%esp)
call printf
addl $1, -8(%ebp)
.L9:
cmpl $7, -8(%ebp)
jle .L10
addl $36, %esp
popl %ebx
popl %ebp
ret
.size printRecords, .-printRecords
.globl getCurrentPlayer
.type getCurrentPlayer, @function
getCurrentPlayer:
pushl %ebp
movl %esp, %ebp
movb $74, currentPlayer
movb $75, currentPlayer+1
movb $65, currentPlayer+2
movl $92, currentPlayer+4
popl %ebp
ret
.size getCurrentPlayer, .-getCurrentPlayer
.globl updateRecords
.type updateRecords, @function
updateRecords:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $0, -8(%ebp)
jmp .L16
.L17:
addl $1, -8(%ebp)
.L16:
movl currentPlayer+4, %eax
movl -8(%ebp), %edx
movl topRecords+4(,%edx,8), %edx
cmpl %edx, %eax
jge .L18
cmpl $7, -8(%ebp)
jle .L17
.L18:
movl $7, -4(%ebp)
jmp .L20
.L21:
movl -4(%ebp), %ecx
movl -4(%ebp), %eax
subl $1, %eax
movl topRecords+4(,%eax,8), %edx
movl topRecords(,%eax,8), %eax
movl %eax, topRecords(,%ecx,8)
movl %edx, topRecords+4(,%ecx,8)
subl $1, -4(%ebp)
.L20:
movl -4(%ebp), %eax
cmpl -8(%ebp), %eax
jg .L21
movl -8(%ebp), %ecx
movl currentPlayer, %eax
movl currentPlayer+4, %edx
movl %eax, topRecords(,%ecx,8)
movl %edx, topRecords+4(,%ecx,8)
leave
ret
.size updateRecords, .-updateRecords
.comm topRecords,70,32
.comm currentPlayer,8,4
.ident "GCC: (GNU) 4.1.2 20080704 (Red Hat 4.1.2-44)"
.section .note.GNU-stack,"",@progbits
ne suggestions or possible solution ...???
if u have ne doubts regarding the problem please dont hesitate to ask....thanks,....
any suggestions and help is highly appreciated..
...
thank you...