Link to home
Start Free TrialLog in
Avatar of mohet01
mohet01Flag for India

asked on

BRNZ(ra,label,rc) - assembly instruction

Hello
In DEC-alpha instruction set, one instruction is
BRNZ ra C rc
//where opcode(BRNZ) takes 5 bits, ra takes 5 bits(ra stores value 0 or 1), constant C takes 16 bits and rc takes 5 bits
//action performed is: programcounter PC <- <PC> + label

I think we use this instruction for if statements in C language.

My question is:
As label is constant we can move only 2^16 addresses from the current address.
So, Is that not a problem?because the next instruction to execute would exceed the known max 2^16 distance in memory

Sham
Avatar of pmasotta
pmasotta

in the x86 world there are opcodes for short jumps and long jumps
probably DEC has a similar strategy using different opcodes upon the code needs
in general the isntructions with short jumps are shorter than instructions with long jumps
this makes the code more size efficient
Avatar of mohet01

ASKER

if we assume writing a program in x86
Can u give an example of short jumps and long jumps usage which will resolve my problem?
Sham
ie x86 JNB "Jump if not below"

opcode short jump: 0x73
opcode near jump: 0x0F 0x83
As you see the nemonic is the same.
but of course the opcode is chosen by the assembler program when assembling your code you do not have to worry about what opcode to use. It is the assembler who calculates how far your jump is and uses the right opcode
Avatar of mohet01

ASKER

I did not get the above update about the syntax of assembly instructions

1) How do you mention this short/near/long jump instructions in if() block of c language?
2) please let me know the corresponding syntax of assembly instruction for C's short/near/long jump instruction?

In DEC -alpha i know one following instruction:

JMP ra rc
//ra and rc are registers
//action performed: pc <- <ra>
//ra has the address to which PC points to, but am not sure if this used in if() blocks



Sham

ASKER CERTIFIED SOLUTION
Avatar of pmasotta
pmasotta

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mohet01

ASKER

Perfect pma
Avatar of mohet01

ASKER

Hello

i have a query in
ID: 27178090

Can you please help me answer by reading just my last update and last second update

I for got to include assembler zone this that query


Sham

Avatar of mohet01

ASKER

Perfect
Avatar of mohet01

ASKER

Hello pma
Can you help answering query in ID: 27178090

Sham
just did it...