Warning: Undefined array key "hide_archive_titles" in /home1/smartva9/public_html/smartvania/wp-content/themes/baton/includes/theme-functions.php on line 254

Category: LTS

Code Request

I was watching your videos on youtube about assembly, but I have many doubts… I have an exercise to do until next Sunday, and I don’t know how to do it!
The steps are:

A) Send the message: “Enter your registration number”;
B) Receive 9 numeric digits corresponding to a registration number;
C) If the registration is all zero, and the program (call the system with the exit operation)
D) Search in the registrations stored as constants in the program
D.1) If you find the registration, present the text:
“The registration number XXXXXXXXX corresponds to student YYYYYYYY.”
D.2) If you can not find the registration, please submit the text:
“Registration XXXXXXXXX was not found”
D.3) If the registration number corresponds to your registration number, present the text:
“It’s me! I’M YYYYY YYYYY YYYY and my register number is XXXXXXXXX ”
E) Go back to step “A”

The names must be stored using .asciiz and the registration numbers must be stored as a 32-bit integer, formatted as BCD, that is, every 4 bits, we have a decimal digit. The first number of the register number is always 1 and should not be stored. Registration example: 112345678 will be stored in hexadecimal as
12345678h (binary 0001_0010_0011_0100_0101_0110_0111_1000);

See below:

# Partially completed solution.
.data
message: .asciiz "Enter your registration number: "
found_message: .asciiz "The registration number XXXXXXXXX corresponds to student YYYYYYYY.\n"
not_found_message: .asciiz "Registration XXXXXXXXX was not found.\n"
my_number_found_message: .asciiz "It's me! I'M YYYYY YYYYY YYYY, and my register number is XXXXXXXXX.\n"
registration_names: .asciiz "XXXXXX", "YYYYYY"
registration_numbers: .word 0x0000000, 0x000000
my_number: .word 0x000000

.eqv ARRAY_SIZE 8 # 2 ints = 8 bytes
.text
main:
loop:
# Show prompt.
li $v0, 4
la $a0, message
syscall

# Get input.
li $v0, 5
syscall

# If all 0's, then end program.
move $a0, $v0
beqz $a0, main_exit

# Search (pass value to search in $a1).
move $a1, $a0
jal search_registration

b loop

main_exit:
li $v0, 10
syscall

# Expects user input in $a1.
search_registration:
# $t1 is loop index. $t2 is my number.
li $t1, 0
search_loop:
lw $a0, registration_numbers($t1)
beq, $a0, $a1, number_found
addi $t1, $t1, 4
beq $t1, ARRAY_SIZE, number_not_found
blt $t1, ARRAY_SIZE, search_loop

number_found:
lw $t2, my_number
beq $a0, $t2, my_number_found
li $v0, 4
la $a0, found_message
syscall

b search_registration_exit
my_number_found:
li $v0, 4
la $a0, my_number_found_message

syscall
b search_registration_exit
number_not_found:
li $v0, 4
la $a0, not_found_message
syscall
search_registration_exit:
jr $ra

MIPS questions

Hi Amell,

I just watched the entire series of MIPS tutorial that you have uploaded on your YT channel. First of all, thanks for that! It was awesome 🙂

Secondly, I have a few questions. As I am completely new to MIPS, I have received some tasks to do (from school) and do not know how they should be configured. Do you mind looking over them and give me some hints?

For analyze.asm:
Change the program so that only every third character is printed. The program must still stop after “Z”.

For hexmain.asm:
You will now write a small subroutine, that converts numbers in the range 0 through 15 into a printable ASCII-coded character: ‘0’ through ‘9’, or ‘A’ through ‘F’, depending on the number. For numbers not in the range 0 through 15, some bits will be ignored. In file hexmain.asm, add an assembly-language subroutine with the following specification. Name: The subroutine must be called hexasc. Parameter: One, in register $a0. The 4 least significant bits specify a number, from 0 through 15. All other bits in register $a0 can have any value and must be ignored. Return value: The 7 least significant bits in register $v0 must be an ASCII code as described below. All other bits must be zero when your function returns. Required action: The function must convert input values 0 through 9 into the ASCII codes for digits ‘0’ through ‘9’, respectively. Input values 10 through 15 must be converted to the ASCII codes for letters ‘A’ through ‘F’, respectively.

Thanks in advance!

Best regards,
A.
01/3/17

# hexmain.asm

# Written
2015-09-04
by F Lundevall

# Copyright abandonded
– this file is
in the public domain.

.text

main:

li
$a0,3
# change this to test different values

jal hexasc #
call hexasc

nop # delay
slot filler (just in case)

move
$a0,$v0
# copy return value to argument register

li
$v0,11
# syscall with v0 =
11 will print
out

syscall # one
byte from a0 to the Run I/O window

stop: j stop # stop after one run

nop # delay
slot filler (just in case)

# You can write your own code for hexasc here

#

hexasc:

andi
$a0,
$a0,
0xF # remove all bits except the
4 lsb.

addi
$v0,
$0,
0x30

addi
$t0,
$0,
0x9

ble
$a0,
$t0,
converter

nop

addi
$v0,
$v0,
0x7

converter:

add
$v0,
$a0,
$v0

jr
$ra

nop

-Amell

Code Request

Sir, can you please make quadratic equation solver in assembly or just
square root function I’m having a problem in square root part please
help?
Raj

2016-03-25 08:14

See below:
#——————————————————————————————
# Subroutine: sqrt
# Usage: v0 = sqrt(a0)
# Description:
# Takes a positive signed integer in $a0 and returns its integer square root
# (i.e., the floor of its real square root) in $v0.
# Arguments: $a0 – A positive signed integer to take the square root of.
# Result: $v0 – The floor of the square root of the argument, as an integer.
# Side effects: The previous contents of register $t0 are trashed.
# Local variables:
# $v0 – Number r currently being tested to see if it is the square root.
# $t0 – Square of r.
# Stack usage: none
#——————————————————————————————
sqrt: addi $v0, $zero, 0 # r := 0
loop: mul $t0, $v0, $v0 # t0 := r*r
bgt $t0, $a0, end # if (r*r > n) goto end
addi $v0, $v0, 1 # r := r + 1
j loop # goto loop
end: addi $v0, $v0, -1 # r := r – 1
jr $ra # return with r-1 in $v0

-Amell

Java is difficult to me

Hi Mrs. Yanilda,
I wish you are doing well, I am a Computer Science student, a fourth year, at International Islamic University Malaysia, I have a problem with a java Tools like Classes, objects and methods and very interesting this course, so could please suggest to any syllabus, Videos or any easy that i can learn this course. Moreover, how can improve my computer Skills?
Thanks

March 03/2016

Dear Comp. Science Student,
Thank you for reaching out to me. I am doing very well and hoping you are doing well too. To learn java, I will recommend you for things: Read-Watch-Practice-Debug.
• Read: Java: How to Program by Deitel, latest edition.
• Watch: Bucky’s Java Tutorial on Youtube
• Practice: Browse on the web projectEuler.net
• Debug: Test your programs, and analyze other people’s code.
Though there are many other resources on the internet, you can browse some tutorials on the web, check: http://www.tutorialspoint.com/java/
I hope this could help you. Also remember the key is to practice, practice, practice.
Sincerely,
Yanilda P. R.

Your mips tutorial #4 on printing a character

Letters

The correct code for printing characters is 11, not 4, and you should always use single quotes for characters.

http://courses.missouristate.edu/KenVollmar/mars/Help/SyscallHelp.html

What you actually did in the tutorial is to print a string that is one character long, and that is a different thing. You were lucky (or perhaps unlucky) that the next byte after your character happened to be zero and therefore terminated the string for you. When you use syscall code 4, it will print until it gets to a zero byte.

For example, try this code. It prints \”mabc\”.

.data
chr: .byte \’m\’
.byte \’a\’
.byte \’b\’
.byte \’c\’

.text

li $v0 4
la $a0 chr
syscall

This code does the right thing:

li $v0 11
lb $a0 chr
syscall

as does this:

li $v0 11
li $a0 \’m\’
syscall

One other thing: there\’s an assemble button right next to the run button, so you don\’t have to go to the menu to assemble your file.

12-10-15

Dear sender,

Thank you very much for the correction. We will fix this.

Sincerely,
Smartvania

Mars program

Letters

Hello!
I saw your MIPS Tutorial 1 that is uploaded in YOUTUBE.
In that video, you introduce how to download Mars program.
I did your process but when I double click Mars4_5.jar file, it doesn’t work.
java JDK is already downloaded.
I don’t know why this file doesn’t work and what should I do.
Could you tell me the reason and how to execute that file?
Thanks!!

2015-10-15

Hi dear reader,

If you haven’t solved this issue by this time, kindly please contact us at contact@smartvania.com

Sincerely,
SmartVania

Appreciation

Letters

Great doing.keep going and all success.God bless you!

2015-08-16

Thank you so much for the encouragement :).

Sincerely,
Smartvania

MIPS

Hello will you continue to make more MIPS tutorials?

2015-01-14

Yes, we are, now we have an entire series of tutorials of MIPS with 30 videos on Youtube. Click on the Tutorials tab of the menu.

Sincerely,
SmartVania

Hello Yanilda :D from: Gopal

Hello Yanilda,

My name is Gopal, I’m a Mauritius-based Computer Science(Level 1) student at the University of Mauritius.

Umm..actually I’m currently doing a module: Computer Architecture in which we have assembly programming(MIPS)..and when I came by your website and saw all those great tutorials about MIPS..I was I like delighted.

Just wanted to say Thank you for those great tutorials.

2015-02-26

Hello dear Gopal,

I’m happy to see that the assembly tutorials were of your help. Since This website is under construction, we are still adding more content, please stay in tune and thank you for writing to us.

Sincerely,
Yanilda

Assembly help

Letters

Hi,

Love your videos/tutorials on Assembly they’ve helped me a lot over the past couple of days.
But, there’s still many things i quite don’t understand when it comes to assembly language.
I’m trying to compute a program that prints the number of times each element is repeated,
eg) if the user inputs: [1 5 7 5 2 5 3 4 1 9]
The program will print:
1:2
5:3
7:1
2:1
3:1
4:1
9:1

Any help would be appreciated! I am trying to understand Assembly as much as possible.

Greatly appreciated!

2015-03-26

Student

Letters

I’m a student of electrical computer engineering, and now in 5th semester. in this semester we are studying computer organization which has a small parts of MIPS… kindly help me in MIPS basics.
thank you

Hanif

2015-09-19

Dear Hanif,

Thank you for reaching out to us. Please watch the Entire series of the basics for MIPS on Youtube or click on Tutorials >> Assembly language.
Please keep tuned for more content.

Sincerely,
Yanilda