Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.

where can I get the reference of pseudo-code?

Raymond_S_
Beginner
914 Views

Hi,

When I read the book "Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 2 (2A, 2B & 2C):Instruction Set Reference", each instruction has some pseudo-code, for example:

IF 64-Bit Mode
THEN
#UD;
ELSE
tempAL ← AL;
tempAH ← AH;
AL ← (tempAL + (tempAH ∗ imm8)) AND FFH;
(* imm8 is set to 0AH for the AAD mnemonic.*)
AH ← 0;
FI;

And "Intrinsics Guide" is also described by pseudo-code(https://software.intel.com/sites/landingpage/IntrinsicsGuide/),  for example:

Operation

FOR j := 0 to 7
i := j*16
dst[i+15:i] := ABS(a[i+15:i])
ENDFOR
 
My question is: where can I get reference or guide or introduction of these pseudo-codes? I mean the grammar of the pseudo-codes.
 
Thanks.
0 Kudos
4 Replies
jimdempseyatthecove
Honored Contributor III
914 Views

Psudo code may vary from author to author, and potentially from document to document from the same author. When well written, the pseudo coded should be well understood by someone who's had some programming experience.

In the first case, you would (potentially) look like an IF THEN ELSE ENDIF type of programming structure except you do not see ENDIF, instead you see FI (IF spelled backwards). So this dialect appears to substitute FI for ENDIF. The first example also appears to use statements terminated with a semicolon (;), and use left arrow for assignment. You may find in the front of the book (first book) a glossary of terms to define what #UD means. Sight unseen, I would guess "Undefined" and the processor potentially would issue a fault. Comments appear to be using (* for open quote, and *) for close quote. It is relatively easy to grasp this.

The second example appears to use the := token for assignment as opposed to left arrow, and the FOR statement spells out the range instead of using comma separator. Why it does not use ROF for ENDFOR I cannot say, but regardless of choice of token, you would interpret the pseudo code correctly (the brain is capable of making sense out of fuzzy input).

In the second example:

FOR j := 0 to 7
  i := j*16
  dst[i+15:i] := ABS(a[i+15:i])
ENDFOR

You have to be mindful that the instruction set inside the CPU may have bit fields. The above appears to describe copying the absolute value of 8 16-bit bit fields from "a" into "dst".

Sometimes pseudo code is written in an actual language...
... but with the understanding that the pseudo code may violate something in the language and/or may have expressive or misspelled terms.

The point of the pseudo code is to convey the information, presumably in a better understanding way than actual code.

Jim Dempsey

0 Kudos
Raymond_S_
Beginner
914 Views

thanks you for your answer.

jimdempseyatthecove wrote:

Psudo code may vary from author to author, and potentially from document to document from the same author. When well written, the pseudo coded should be well understood by someone who's had some programming experience.

In the first case, you would (potentially) look like an IF THEN ELSE ENDIF type of programming structure except you do not see ENDIF, instead you see FI (IF spelled backwards). So this dialect appears to substitute FI for ENDIF. The first example also appears to use statements terminated with a semicolon (;), and use left arrow for assignment. You may find in the front of the book (first book) a glossary of terms to define what #UD means. Sight unseen, I would guess "Undefined" and the processor potentially would issue a fault. Comments appear to be using (* for open quote, and *) for close quote. It is relatively easy to grasp this.

The second example appears to use the := token for assignment as opposed to left arrow, and the FOR statement spells out the range instead of using comma separator. Why it does not use ROF for ENDFOR I cannot say, but regardless of choice of token, you would interpret the pseudo code correctly (the brain is capable of making sense out of fuzzy input).

In the second example:

FOR j := 0 to 7
  i := j*16
  dst[i+15:i] := ABS(a[i+15:i])
ENDFOR

You have to be mindful that the instruction set inside the CPU may have bit fields. The above appears to describe copying the absolute value of 8 16-bit bit fields from "a" into "dst".

Sometimes pseudo code is written in an actual language...
... but with the understanding that the pseudo code may violate something in the language and/or may have expressive or misspelled terms.

The point of the pseudo code is to convey the information, presumably in a better understanding way than actual code.

Jim Dempsey

0 Kudos
Amir_K_2
Beginner
914 Views

I found this . Might help you . i am a newbie so :0

http://refspecs.linux-foundation.org/IA64-softdevman-vol1.pdf

0 Kudos
Bernard
Valued Contributor I
914 Views

@Amir

You uploaded Intel Itanium Programming Manual which is not so relevant neither to you nor to us. I suppose that you should have a look at Intel Intel 64 and IA-32 manuals.

http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html

0 Kudos
Reply