Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
16 views6 pages

Assembly&C Language

The document outlines basic assembly language instructions, including branching based on zero conditions (CBZ, CBNZ), unconditional branching (B), and a return instruction (BR). It also provides an example of a factorial function implemented in assembly, demonstrating stack management and recursive calls. Additionally, it mentions the relationship between bits and bytes in the context of array element location.

Uploaded by

macbay prince
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

Assembly&C Language

The document outlines basic assembly language instructions, including branching based on zero conditions (CBZ, CBNZ), unconditional branching (B), and a return instruction (BR). It also provides an example of a factorial function implemented in assembly, demonstrating stack management and recursive calls. Additionally, it mentions the relationship between bits and bytes in the context of array element location.

Uploaded by

macbay prince
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Assembly C Python

1. CBZ --> Branch if Zero

e.g;
CBZ X9, L1

If X9 == 0, go toL1

2. CBNZ --> Branch if Zero

e.g;
CBNZ X9, L1

If X9 != 0, go to L1

3. B --> Unconditional Branch

e.g;
B L1

Jump to L1

4. SUB X9, X22, X23 --> Compare i and j If (i == j)


f = g + h;
CBNZ X9, Else --> if i !=j, jump to Else Else
f = g - h;
AD X19, X20, X21 --> f = g + h

B Exit --> Skip Else

Else:

SUB X19, X20, X21 --> f = g - h

Exit:

5. BR --> Return to caller

6. fact:
SUBI SP, SP, #16 // Allocate stack
space
STUR LR, [SP, #8] // Save return
address
STUR X0, [SP, #0] // Save argument n
SUBIS XZR, X0, #1 // Compare n with 1
B.GE L1 // If n >= 1, continue
ADDI X1, XZR, #1 // Return 1 for base
case
ADDI SP, SP, #16 // Restore stack
BR LR // Return
L1:
SUBI X0, X0, #1 // n = n - 1
BL fact // Recursive call
MUL X1, X0, X1 // Multiply n *
fact(n-1)
BR LR // Return

C:\Program Files (x86)\CodeBlocks\MinGW\bin


8 Bits = 1 Byte
We use the number of bits to get the location of an element in an array

You might also like