Tutorial for Fortran / Machine Language

in utopian-io •  7 years ago  (edited)

GitHub Repository:https://github.com/wavebitscientific/functional-fortran
Fortran (FORTRAN) is a general purpose, procedural, mandatory programming language, particularly suitable for numerical computation and scientific computing.

Fortran

The first version for the IBM 704, produced by IBM in 1954, was developed by John Backus and his team. Backus and his team published a report in November 1954 entitled "The IBM Mathematical FORmula TRANslating System: Fortran".

What Will I Learn?

  • I will try to give you information about the use of Fortran Programming Language. This series will proceed step by step. At the end of our project, we will have learned the Fortran Programming and Calculus Language. I will strive to give you a useful education.

Requirements

  • To develop and examine the concept of problem solving
  • Thinking and developing other things while solving problems
  • Force 2.0

Difficulty

  • Intermediate

Curriculum




Machine language

X = A * B + C
  • Take the value at the address to ALU the memory, load into "register";
  • Take the value from memory address B, multiply by value and hold the same ''register'' at the end.
  • The value at memory address C is the register value add.
  • Put the value in the register at the X address of the memory

Machine language example

X = A * B + C
Opcode Operand
1) 00010000000000000000010000000000 (A’daki değeri reg. yükle)
Hex: 08 00 04 00
2) 00100100000000000000010000000001 (B’deki değerle çarp)
Hex: 24 00 04 01
3) 00100011000000000000010000000010 (C’deki değeri reg. ile topla)
Hex: 23 00 04 02
4) 00010001000000000000010000000011 (Registerdeki değeri X’e taşı)
Hex: 11 00 04 03
İki tabanındaki sayılar : 0, 1
Ondalık sayılar : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Onaltılık (hex) sayılar : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

A little more hex

Ondalık -> Hex 
1 = 1
10 = A
36 = 24 
147 = 93 
255 = FF

Machine language - Assembler

X = A * B + C
08 00 04 00
24 00 04 01
23 00 04 02
11 00 04 03

How to solve an engineering problem?

Beam Core, Let's Graduate in a Diploma. He is the core physicist at the University. For the experiment, 10 mg. It's polonium. Then forgotten 180 days past. Polonium has a half-life of 140 days. Now you have it. How many mg Po is left?

  • Inputs
    Starting quantity: 10 mg
    Half life: 140 days
    Elapsed time: 180 days

  • Output /
    Amount left ?

Let's name the data a bit more generalized and the problem:

Inputs

  • Starting amount:
BaslangicMiktari
  • Half life:
YariOmur
  • Elapsed time:
GecenZaman

Output

  • Remaining amount:
KalanMiktarı

Calculation algorithm rule

BaslangicMiktari, YariOmur, GecenZaman

read values.

KalanMiktar

calculate

KalanMiktar

write value

Now we can solve the problem

IMPLICIT NONE
REAL :: BaslangicMiktari, YariOmur, GecenZaman, KalanMiktar
! BaslangicMiktari, GecenZaman, YariOmur read values
PRINT *, “Başlangıç miktarı, yarı ömür ve gecen zaman enter the values: ”
READ *, BaslangicMiktari, YariOmur, GecenZaman
! KalanMiktar = BaslangicMiktari * 0.5**(GecenZaman/YariOmur) calculate
KalanMiktar = BaslangicMiktari * 0.5 ** (GecenZaman / YariOmur)
! KalanMiktar write value
PRINT *, “Kalan miktar =“, KalanMiktar, “mg”
END PROGRAM Radyoaktif_Bozunma

Let's summarize what we've done here

  • Algorithm I got the head and the tail.
  • Data input and we made the exit.
  • Operation
  • Flow according to a decision two (or more way): Road A fork.
  • Loop
  • One sub procedure-sub algorithm

FORTRAN expressions we learned

  • PROGRAM: program-name
PROGRAM Radyoaktif_bozunma
IMPLICIT NONE
  • REAL :: variable-names-list
REAL :: BaslangicMiktari, GecenZaman
INTEGER :: OgrenciSayisi, OgrenciNumarasi

Input expression

  • READ *, To be read-variables-list
READ *, BaslangicMiktari, YariOmur, GecenZaman

Output expression

  • PRINT *, Will be written-variables-list
PRINT *, “The remaining amount = ”, KalanMiktar, “mg”
  • WRITE(,) Will be written-variables-list
WRITE(*, *) “The remaining amount = ”, KalanMiktar, “mg”

Assignment expression

  • değişken = expression
Delta = b*b – 4.* a * c
 KalanMiktar = BaslangicMiktari * 0.5 ** (GecenZaman / YariOmur)

ATTENTION: This is not an algebraic equation. In some languages ​​= instead used. Things like A * b = c + d can not be written.

Bitiş: END program-ismi
 END Radyoaktif_bozunma

So we learned how to solve engineering questions. If we put the values ​​in the queries into the given codes, we can solve the convenience.



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Your contribution cannot be approved because it does not follow the Utopian Rules, and is considered as plagiarism. Plagiarism is not allowed on Utopian, and posts that engage in plagiarism will be flagged and hidden forever.

Plagiarised from here.

You can contact us on Discord.
[utopian-moderator]

Hey @amosbastian, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!