flat assembler
Message board for the users of flat assembler.

Index > Main > I not found Call NZ and Call Z on x86. ZX-Spectrum have.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 29 Dec 2018, 15:47
I was surprised when I did not find on x86
Call NZ and Call Z
Ret NZ and Ret Z

Useful commands.

On zx-spectrum was this commands.
Post 29 Dec 2018, 15:47
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 29 Dec 2018, 15:50
emulation CAll nz
Code:
         cmp eax,10
         push lab1
         jnz ProcDoSomeCode
lab1:
    


Code:
ProcDoSomeCode:
    some code
    ret
    
Post 29 Dec 2018, 15:50
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 715
Ali.Z 29 Dec 2018, 18:56
yeah really, it miss the conditional call.

but it can be implemented as:

Code:
there:
; somecode
pushf
pop ax
and al,40h
jnz here
call there ; callz
here:
; some code    


Code:
there:
; somecode
pushf
pop ax
and al,40h
jz here
call there ; callnz
here:
; some code    

_________________
Asm For Wise Humans
Post 29 Dec 2018, 18:56
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 29 Dec 2018, 19:58
Roman wrote:
emulation CAll nz
Code:
         cmp eax,10
         push lab1
         jnz ProcDoSomeCode
lab1:
    
And very slow on modern CPUs with call return buffers / predictors. Wink

Also it always pushes, I don't think that's intentional and probably a bug (I don't know about ZX Spectrum).

Why not keep it simple like:
Code:
cmp eax, 10
jz @f
call ProcDoSomeCode
@@:    
Post 29 Dec 2018, 19:58
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 30 Dec 2018, 07:57
Furs
Yes good too
Code:
cmp eax, 10
jz @f
call ProcDoSomeCode
@@: 
    


ZX-Spectrum was in 1982 !!!


I just show on example how useful Call Z or Call NZ.
One Call Nz or write 3 line code.
Post 30 Dec 2018, 07:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 30 Dec 2018, 08:54
ARM in 32-bit mode can also do conditional calls.

But in 64-bit code that was eliminated.

C code compilers can't generated conditional call instructions, so the instructions are unused by most software. Therefore the CPU makers found no compelling reason to include it in the instruction set. And, as we all know, no one writes assembly code directly, by hand. OMG, that would be just too difficult for any human to do. Laughing
Post 30 Dec 2018, 08:54
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:  


< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.