Warning: Undefined array key "hide_archive_titles" in /home1/smartva9/public_html/smartvania/wp-content/themes/baton/includes/theme-functions.php on line 254
Author: SmartVania
Temperature Conversion Formulas
Fahrenreit | Celcius | Kelvin | |
---|---|---|---|
Fahrenheit(F) | F | (F-32)*5/9 | ((F-32)*5/9)+273.15 |
Celsius(C) | (C*9/5) + 32 | C | C + 273.15 |
Kelvin(K) | (K-273.15)*9/5 +32 | K – 273.15 | K | Fahrenreit | Celcius | Kelvin |
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 Tutorial 38 – 2D Array Implementation
2D Arrays (MIPS) a brief explanation
Average Program (MIPS)
Bit Manipulation (MIPS Tutorial)
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
Trust in your intuitions
When you are alone for days or weeks at a time, you eventually become drawn to people. Talking to randos is the norm. I’ll never forget the conversation with the aquarium fisherman, forest ranger, and women at the Thai market. It’s refreshing to compare notes on life with people from vastly different backgrounds.
Continue ReadingCode 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
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
syscallThis code does the right thing:
li $v0 11
lb $a0 chr
syscallas does this:
li $v0 11
li $a0 \’m\’
syscallOne 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