flat assembler
Message board for the users of flat assembler.
Index
> Windows > Math logic |
Author |
|
Tyler 06 Jun 2010, 03:02
Yeah, that makes sense, what about it? But IMO, dividing in asm is a pain. I'm too lazy to use asm for anything that needs dividing .
|
|||
06 Jun 2010, 03:02 |
|
LocoDelAssembly 06 Jun 2010, 03:32
Note sure what you're actually want so I've decided to guess and write this program
Code: format pe console include 'win32ax.inc' mov ebx, 1 .loop: mov eax, ebx mov esi, 0 mov ecx, 1000 xor edx, edx div ecx push edx test eax, eax jz .print inc esi mov ecx, 60 xor edx, edx div ecx push edx test eax, eax jz .print inc esi xor edx, edx div ecx ; ECX IS STILL 60 HERE push edx test eax, eax jz .print inc esi mov ecx, 24 xor edx, edx div ecx push edx test eax, eax jz .print inc esi push eax .print: push [strTab+esi*4] call [printf] lea esp, [esp+esi*4+8] add ebx, ebx jnc .loop cinvoke system, cmd invoke ExitProcess, 0 strTab dd fmtMs, fmtSeg, fmtMin, fmtHs, fmtDays fmtMs db "%u millisecond(s).", 13, 10, 0 fmtSeg db "%u second(s) and %u millisecond(s).", 13, 10, 0 fmtMin db "%u minute(s), %u second(s) and %u millisecond(s).", 13, 10, 0 fmtHs db "%u hour(s), %u minute(s), %u second(s) and %u millisecond(s).", 13, 10, 0 fmtDays db "%u day(s), %u hour(s), %u minute(s), %u second(s) and %u millisecond(s).", 13, 10, 0 cmd db "pause", 10, 0 align 4 ; Just to be safe data import library kernel32, 'kernel32.dll',\ msvcrt,'msvcrt.dll' include 'api/kernel32.inc' import msvcrt,\ printf, 'printf',\ system, 'system' end data Code: 1 millisecond(s). 2 millisecond(s). 4 millisecond(s). 8 millisecond(s). 16 millisecond(s). 32 millisecond(s). 64 millisecond(s). 128 millisecond(s). 256 millisecond(s). 512 millisecond(s). 1 second(s) and 24 millisecond(s). 2 second(s) and 48 millisecond(s). 4 second(s) and 96 millisecond(s). 8 second(s) and 192 millisecond(s). 16 second(s) and 384 millisecond(s). 32 second(s) and 768 millisecond(s). 1 minute(s), 5 second(s) and 536 millisecond(s). 2 minute(s), 11 second(s) and 72 millisecond(s). 4 minute(s), 22 second(s) and 144 millisecond(s). 8 minute(s), 44 second(s) and 288 millisecond(s). 17 minute(s), 28 second(s) and 576 millisecond(s). 34 minute(s), 57 second(s) and 152 millisecond(s). 1 hour(s), 9 minute(s), 54 second(s) and 304 millisecond(s). 2 hour(s), 19 minute(s), 48 second(s) and 608 millisecond(s). 4 hour(s), 39 minute(s), 37 second(s) and 216 millisecond(s). 9 hour(s), 19 minute(s), 14 second(s) and 432 millisecond(s). 18 hour(s), 38 minute(s), 28 second(s) and 864 millisecond(s). 1 day(s), 13 hour(s), 16 minute(s), 57 second(s) and 728 millisecond(s). 3 day(s), 2 hour(s), 33 minute(s), 55 second(s) and 456 millisecond(s). 6 day(s), 5 hour(s), 7 minute(s), 50 second(s) and 912 millisecond(s). 12 day(s), 10 hour(s), 15 minute(s), 41 second(s) and 824 millisecond(s). 24 day(s), 20 hour(s), 31 minute(s), 23 second(s) and 648 millisecond(s). Presione una tecla para continuar . . . PS: The code was meant to be straightforward, not size nor speed optimization was attempted. |
|||
06 Jun 2010, 03:32 |
|
FrozenKnight 01 Jul 2010, 10:33
What you could do is use multiplication and take advantage of overflow.
|
|||
01 Jul 2010, 10:33 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.