100% found this document useful (1 vote)
231 views12 pages

Assembly Beta ISA Introduction

This document provides information about assembly language programming using the Beta instruction set architecture, including: - A link to an online Beta simulator called BSim Sandbox for testing programs. - Reference material and tutorial videos on using BSim and examples of Beta programs. - Tables describing the Beta instruction set with opcodes, syntax, and descriptions of common arithmetic, logical, comparison, branching, and memory instructions. - 20 practice problems for writing Beta assembly programs to perform tasks like array manipulation, math operations, and sorting algorithms.

Uploaded by

Dương Dũng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
231 views12 pages

Assembly Beta ISA Introduction

This document provides information about assembly language programming using the Beta instruction set architecture, including: - A link to an online Beta simulator called BSim Sandbox for testing programs. - Reference material and tutorial videos on using BSim and examples of Beta programs. - Tables describing the Beta instruction set with opcodes, syntax, and descriptions of common arithmetic, logical, comparison, branching, and memory instructions. - 20 practice problems for writing Beta assembly programs to perform tasks like array manipulation, math operations, and sorting algorithms.

Uploaded by

Dương Dũng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

CEA201

ASSEMBLY LANGUAGE
MASSACHUSETTS INSTITUTE OF TECHNOLOGY
BETA Instruction Set Architecture
Online simulator
BSim Sandbox:
http://computationstructures.org/exercises/sandbox
es/bsim.html

--> Click: Open BSim in a new window to open editor


and simulation.
Reference material:
Appendix_β Documentation.pdf

Tutorial :
Giới thiệu phần mềm BSIM: https://youtu.be/FYT38vagylg
Exam 1: https://youtu.be/NVfPtZpZh6M (Bài cơ bản)
Exam 2: https://youtu.be/AepuJT7Fsmc (symbol, label, mảng)
Exam 3: https://youtu.be/IBmPbye9QLQ (vẽ flowchat, đổi giá trị có điều kiện)
Exam 4: https://youtu.be/l3_n73GFV0g (xđ 3 giá trị có phải 3 cạnh tam giác ko)
Exam 5: https://youtu.be/39CRGA5nwHg (tìm min của 3 ô nhớ)
Exam 6: https://youtu.be/FmneWSSbTlI (tìm ước số chung lớn nhất)
Exam 7: https://youtu.be/j5U9ck1bB40 (tính tổng chuỗi số)
Opcde Systax Description
LD LD(Ra,literal,Rc) Rc ← Mem[Ra + literal]
LDR LDR(label,Rc) Rc ← Mem[Label]
ST ST(Rc,literal,Ra) Mem[Ra + literal] ← Rc
ADD ADD(Ra,Rb,Rc) Rc ← Ra + Rb
ADDC ADDC(Ra,literal,Rc) Rc ← Ra + literal
SUB SUB(Ra,Rb,Rc) Rc ← Ra − Rb
SUBC SUBC(Ra,literal,Rc) Rc ← Ra − literal
MUL MUL(Ra,Rb,Rc) Rc ← Ra * Rb
MULC MULC(Ra,literal,Rc) Rc ← Ra * literal
DIV DIV(Ra,Rb,Rc) Rc ← Ra / Rb
DIVC DIVC(Ra,literal,Rc) Rc ← Ra / literal
AND AND(Ra,Rb,Rc) Rc ← Ra & Rb
ANDC ANDC(Ra,literal,Rc) Rc ← Ra & literal
OR OR(Ra,Rb,Rc) Rc ← Ra | Rb
ORC ORC(Ra,literal,Rc) Rc ← Ra | literal
XOR XOR(Ra,Rb,Rc) Rc ← Ra ^ Rb
XORC XORC(Ra,literal,Rc) Rc ← Ra ^ literal
XNOR XNOR(Ra,Rb,Rc) Rc ← ~(Ra ^ Rb)
XNORC XNORC(Ra,literal,Rc) Rc ← ~(Ra ^ literal)
Opcde Systax Description
CMPEQ CMPEQ(Ra,Rb,Rc) if Ra = Rb then Rc ← 1 else Rc ← 0
CMPEQC CMPEQC(Ra,literal,Rc) if Ra = literal then Rc ← 1 else Rc ← 0
CMPLE CMPLE(Ra,Rb,Rc) if Ra ≤ Rb then Rc ← 1 else Rc ← 0
CMPLEC CMPLEC(Ra,literal,Rc) if Ra ≤ literal then Rc ← 1 else Rc ← 0
CMPLT CMPLT(Ra,Rb,Rc) if Ra < Rb then Rc ← 1 else Rc ← 0
CMPLTC CMPLTC(Ra,literal,Rc) if Ra < literal then Rc ← 1 else Rc ← 0

BEQ BEQ(Ra,label,Rc) If Ra = 0 branch to label


BNE BNE(Ra,label,Rc) If Ra ≠ 0 branch to label
JMP JMP(Ra,Rc) Branch to address (Ra & 0xFFFFFFFC)

SHL SHL(Ra,Rb,Rc) Rc ← Ra << Rb4:0


SHLC SHLC(Ra,literal,Rc) Rc ← Ra << literal4:0
SHR SHR(Ra,Rb,Rc) Rc ← Ra >> Rb4:0
SHRC SHRC(Ra,literal,Rc) Rc ← Ra >> literal4:0
SRA SRA(Ra,Rb,Rc) Rc ← Ra >> Rb4:0
SRAC SRAC(Ra,literal,Rc) Rc ← Ra >> literal4:0
Exam 1: ALUC Instructions
For the Beta instruction sequence .include "beta.uasm"
shown below, indicate the 32-bit
two's complement values of the ADDC(R31,0x11,R1)
specified registers after the sequence SUBC(R1,-1,R2)
has been executed by the Beta. The DIVC(R2,3,R8)
effect of the instructions is
cummulative, later instructions use HALT()
the values stored by earlier
instructions.

Answer:

Value left in R1?

Value left in R2?

Value left in R8?


Exam 2: ALU Instructions

For the Beta instruction sequence .include "beta.uasm"


shown beside, indicate the 32-bit
ADD(r31, r31, r0)
two's complement values of the
specified registers after the CMPEQ(r0, r31, r1)
sequence has been executed by ADD(r1, r1, r2)
the Beta. MUL(r2, r2, r3)
HALT()

Answer:

Value left in R0?

Value left in R1?

Value left in R2?

Value left in R3?


Practice assembly language exercises

For all exams, you should make use of the Beta documentation and you
can use the Bsim (Beta simulator) to verify the exams.

Note: For complicated assignments, use flowchat or pseodocode.


1. Interchange two contents from a[1] and a[3].

2. Write a program to do the calculation: a[0]=a[1]+a[2]

3. Divide a[0] by a[1], the integer part stored in a[2], the remaining part stored in a[3].

4. a[0] store the value of minutes. Convert the number of minutes to hour and store in a[1] and
store the remaining one in a[2]. (For example: a[0] = 125, then a[1] = 2 and a[2] = 5).

5. a[0] store the value of hours. Convert the number of hours to week and store in a[1] and store
the remaining days in a[2] and the remaining hours in a[3]. (For example: a[0] = 497 then a[1] =
2, a[2] = 6 and a[3]=17.

6. If a[1] > a[3], then interchange.

7. Find the minimum value of a[0], a[1] and a[2], the result is stored in a[3].

8. Find the maximum value of a[0], a[1] and a[2], the result is stored in a[3].

9. Check if a[0], a[1] and a[2] are the lengths of the triangle. If it is true, store 1 to a[3],
otherwise store 0.

10. Sort a[0], a[1] and a[2] in ascending order.


11. Sort a[0], a[1] and a[2] in descending order.
13. Calculate the sum s = 1 + 2 + ... + a[0] and store it to register r0.
14. Calculate the total number of array elements from a[0] to a[9] and
store it to a[10].
15. Find the largest number of array elements from a[0] to a[9] and store
it to a[10].
16. Find the largest common divisor of a[0] and a[1] and store it to a[2].
17. Find the smallest common multiple of a[0] and a[1] and store it to
a[2].
18. Determine if a[0] is prime number or not. If yes, write 1 to a[1],
otherwise write 0.
19. Find the smallest prime number that is greater than a[0], the result is
stored in a[1]. (For example, a[0]=8 then a[1]=11).
20. Determine if a[0] is a square number or not. If yes, write 1 to a[1],
otherwise write 0.
Project - Design Problem: Bubble sort
Write 5 programs using the Assemby language to perform the
following tasks:
Program 1: Write a program to swap two array elements A[5] and A[6]
in Assembly language.
Program 2: Write a program to swap two array elements A[i] and
A[i+1] in Assembly language.
Program 3: Write a program to swap two array elements A[i] and
A[i+1] if A[i]>A[i+1] in Assembly language. (increasing order)
Program 4: Write a program to sort a data array in increasing order
using the "bubble_sort" algorithm.
Program5: Write a program to sort a data array in program 4 using the
“selection sort” algorithm.

You might also like