flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > jecxz "jump out of range" --> first solution Goto page 1, 2 Next |
Author |
|
revolution 03 Apr 2010, 03:25
This can jump up to +-2GB.
Code: test ecx,ecx
jz Somewhere |
|||
03 Apr 2010, 03:25 |
|
sinsi 03 Apr 2010, 03:34
If you need to optimize, using jecxz (and loop) are much slower than a test/jump (or a dec/jnz).
|
|||
03 Apr 2010, 03:34 |
|
LocoDelAssembly 03 Apr 2010, 04:01
On AMD, JECXZ has a two cycles latency and it is a DirectPath instruction. Maybe JECXZ is not always as fast as TEST/J(N)Z is, but still, there may be situations in which you don't want to destroy the flags to find out ECX's current status.
|
|||
03 Apr 2010, 04:01 |
|
Tyler 03 Apr 2010, 04:48
Tomasz uses loop in "convert_line" in preproce.inc
Code: ... mov ebx,characters xor ecx,ecx convert_symbol: lods byte [esi] stos byte [edi] xlat byte [ebx] or al,al loopnzd convert_symbol neg ecx cmp ecx,255 ... |
|||
03 Apr 2010, 04:48 |
|
sinsi 03 Apr 2010, 04:52
>Tomasz uses loop in "convert_line" in preproce.inc
Also uses xlat... Just an observation, not a hard-and-fast rule, since it depends on the cpu. P4 is good with dec and bad with loop and jcxz. P3 is slower with dec. |
|||
03 Apr 2010, 04:52 |
|
ouadji 03 Apr 2010, 06:35
revolution wrote: This can jump up to +-2GB. thank you revolution ... I didn't know that ! sorry, but i'm a beginner in asm. Quote: there may be situations in which you don't want to destroy the flags Last edited by ouadji on 03 Apr 2010, 06:43; edited 1 time in total |
|||
03 Apr 2010, 06:35 |
|
rugxulo 03 Apr 2010, 06:40
sinsi wrote: >Tomasz uses loop in "convert_line" in preproce.inc Also the slow string instructions (lodsb, stosb). Wasn't he writing on a real 386 at one time back in the day?? I'm sure it's smarter to target slow processors that need the extra speed than fast processors that already have it. |
|||
03 Apr 2010, 06:40 |
|
sinsi 03 Apr 2010, 07:45
rugxulo, no argument here, although I haven't programmed recently on less then a P3.
I just latched onto the 'optimize' in the OP. Go to the MASM32 forum and look at all the optimization that goes on there... |
|||
03 Apr 2010, 07:45 |
|
revolution 03 Apr 2010, 08:47
The word "optimise" is so ambiguous. It can mean many things. Optimising for what? Speed? Size? Ease of coding? Ease of reading? Which platform? Which CPU? Under what usage conditions? Hehe, optimise is a dirty word!
|
|||
03 Apr 2010, 08:47 |
|
ouadji 03 Apr 2010, 10:38
no, "optimise" isn't a dirty word. No matter why we search a optimization, speed, size, ease of coding, ease of reading ... it depends on the coding spirit of each developper everyone has his own choice but "car" is a dirty word .. bus, truck, van ? |
|||
03 Apr 2010, 10:38 |
|
revolution 03 Apr 2010, 11:18
Please help me to optimise my code:
Code: ;pretend there is some code here |
|||
03 Apr 2010, 11:18 |
|
bitshifter 03 Apr 2010, 11:25
I help you optimize it for size and readability and speed and everything else...
Code: Hehe |
|||
03 Apr 2010, 11:25 |
|
revolution 03 Apr 2010, 11:29
Wow, it compiled nicely. Thanks bitshifter.
Quote: flat assembler version 1.69.12 (152449 kilobytes memory) |
|||
03 Apr 2010, 11:29 |
|
LocoDelAssembly 03 Apr 2010, 16:20
sinsi wrote: P4 is good with dec P4 is bad in pretty much everything including DEC, you must use "SUB reg/mem, 1" instead. Agner Fog wrote: 16.2 INC and DEC (all Intel processors) |
|||
03 Apr 2010, 16:20 |
|
ouadji 04 Apr 2010, 08:04
LocoDelAssembly, I don't quite understand, tell you about this? Code: mov eax,7 mov ebx,5 x_: sub eax,1 dec ebx jc somewhere jmp x_ |
|||
04 Apr 2010, 08:04 |
|
zhak 04 Apr 2010, 10:19
yes, in this case jump will be taken if CF was set by SUB EAX, 1
|
|||
04 Apr 2010, 10:19 |
|
SeproMan 10 Apr 2010, 14:00
I find the original suggestion by Ouadji a very useful one.
In fact I've incorporated it just a few days ago into my own assembler language project by showing an error message like "Target out of reach by 2 bytes" Thanks Ouadji In FASM "jz Somewhere" has a range of +-2GB. This is not intuitive. I advocate a more WYSIWYG approach jz Somewhere ;[-128,127] jzw Somewhere ;[-32768,32767] jzd Somewhere ;[-2GB,2GB-1] _________________ Real Address Mode. |
|||
10 Apr 2010, 14:00 |
|
revolution 10 Apr 2010, 14:02
in fasm syntax:
jz byte Somewhere ;[-128,127] [edit] byte doesn't compile. What is the byte override? jz word Somewhere ;[-32768,32767] jz dword Somewhere ;[-2GB,2GB-1] The size override forces it to a particular length. |
|||
10 Apr 2010, 14:02 |
|
Tomasz Grysztar 10 Apr 2010, 14:08
Actually, this is not the fasm syntax. The fasm syntax is:
Code: jz short word Somewhere ; [-128;127], EIP masked with 0FFFFh jz short dword Somewhere ; [-128;127] jz near word Somewhere ; [-32768,32767], EIP masked with 0FFFFh jz near dword Somewhere ; [-2GB,2GB-1] |
|||
10 Apr 2010, 14:08 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.