Machine Language Guide-Programming For Aeronautical Engineering And Sciences-Lecture Slides, Slides of Aeronautical Engineering

Prof. Balamohan Pawar delivered this lecture at Allahabad University for Aeronautical Engineering and Computer Programming course. Its main points are: Guide, Programming, Learning, Machine, Register, Load, Store, Label, Instruction, Move

Typology: Slides

2011/2012

Uploaded on 07/20/2012

savitha_48
savitha_48 ๐Ÿ‡ฎ๐Ÿ‡ณ

3

(1)

109 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Machine Language Guide
Basic Program
; Program name : XOR Implementation
;Programmer : Jayakanth Srinivasan
;Last Modified : Feb 18 2003
; code segment
load R1,1 ;Load register R1 with 1
load R2,0xff ;Load register R2 with 11111111
load R3,[first_number] ; move contents of location labeled
; first_number into register R3
xor R4, R3,R2 ; flip the 0's and 1's in the first number
store R4, [result]; store the result in location labeled result
halt ;halt the program.
; data segment
first_number: db 8
result: db 5
Instruction Set
Opcode Instruction Operation
2 RXY load R,XY register[R]:=XY
1 RXY load R,[XY]
3 RXY store R,[XY]
D 0RS load R,[S]
E 0RS store R,[S]
4 0RS move S,R register[S]:=register[R]
5 RST addi R,S,T register[R]:=register[S]+register[T]
integer add
6 RST addf R,S,T register[R]:=register[S]+register[T]
floating-point add
7 RST or R,S,T register[R]:=register[S] OR register[T]
8 RST and R,S,T register[R]:=register[S] AND register[T]
-
-
-
9 RST xor R,S,T register[R]:=register[S] XOR register[T]
A R0X ror R,X register[R]:=register[R] ROR X
B RXY jmpEQ R=R0,XY
0XY jmp XY
F RXY jmpLE R<=R0,X
C 000 halt halt program
The opcode is the first nibble (higher four bits of the first byte) and the three parts of the
operand are the second, third and fourth nibble.
Assembler Syntax
Label
with a digit.
Instruction
16 instructions listed in the previous section.
Comment
Numbers
๎šƒ )
๎šƒ )
The basic template of a machine language program is shown below.
register[R]:=memory[XY]
memory[XY]:=register[R]
register[R]:=memory[register[S]]
memory[register[S]]:=register[R]
bitwise OR
Program Header, Contains
Program Name
Programmer Name
Last Modified
Start of code segment
Start of data segment
bitwise AND
bitwise eXclusive OR
Rotate Right register R for X times
PC:=XY, if R=R0
PC:=XY
PC:=XY, if R<=R0
A label is a sequence of letters, decimal digits and special characters, but it may not start
An instruction starts with a mnemonic, followed by the operands. It has to be one of the
A comment starts after a semicolon โ€˜;โ€™ and ends at the end of the line. Any character is
allowed after the โ€˜;โ€™.
A number can be a decimal number, a binary number or a hexadecimal number.
A decimal number is a sequence of decimal digits ('0' up to '9' . It may start with a
'-' to indicate the number is negative. It may end with a 'd' to emphasize that the
number is decimal.
A binary number is a sequence of binary digits ('0' and '1' and ending with a 'b'.
docsity.com
pf3

Partial preview of the text

Download Machine Language Guide-Programming For Aeronautical Engineering And Sciences-Lecture Slides and more Slides Aeronautical Engineering in PDF only on Docsity!

; Program name Basic Program Machine Language Guide

: XOR Implementation

;Programmer

: Jayakanth Srinivasan

;Last Modified

: Feb 18 2003

; code segment

load

R1,

;Load register R1 with 1

load

R2,0xff

;Load register R2 with 11111111

load

R3,[first_number]

; first_number into register R3; move contents of location labeled

xor

R4, R3,R

; flip the 0's and 1's in the first number

store

R4, [result]

; store the result in location labeled result

halt

;halt the program.

first_number: ; data segment

db

result:

db

Opcode Instruction Set

Instruction

Operation

2

RXY

load

R,XY

register[R]:=XY

1

RXY

load

R,[XY]

3

RXY

store R,[XY]

D

0RS

load

R,[S]

E

0RS

store R,[S]

4

0RS

move

S,R

register[S]:=register[R]

5

RST

addi

R,S,T

register[R]:=register[S]+register[T]

integer add

6

RST

addf

R,S,T

floating-point add register[R]:=register[S]+register[T]

7

RST

or

R,S,T

register[R]:=register[S] OR register[T]

8

RST

and

R,S,T

register[R]:=register[S] AND register[T]

9

RST

xor

R,S,T

register[R]:=register[S] XOR register[T]

A

R0X

ror

R,X

register[R]:=register[R] ROR X

B

RXY

jmpEQ R=R0,XY

0XY

jmp

XY

F

RXY

jmpLE R<=R0,X

C

000

halt

halt program

Numbers Comment 16 instructions listed in the previous section. Instruction with a digit. Label Assembler Syntax operand are the second, third and fourth nibble.The opcode is the first nibble (higher four bits of the first byte) and the three parts of the

The basic template of a machine language program is shown below.

memory[register[S]]:=register[R]register[R]:=memory[register[S]]memory[XY]:=register[R] register[R]:=memory[XY]

bitwise OR

Program Header, Contains

Last ModifiedProgrammer NameProgram Name

Start of data segment Start of code segment

Rotate Right register R for X timesbitwise eXclusive OR bitwise AND

PC:=XY, if R=R PC:=XY, if R<=R0PC:=XY

A number can be a decimal number, a binary number or a hexadecimal number.allowed after the โ€˜;โ€™.A comment starts after a semicolon โ€˜;โ€™ and ends at the end of the line. Any character isAn instruction starts with a mnemonic, followed by the operands. It has to be one of the A label is a sequence of letters, decimal digits and special characters, but it may not start

A binary number is a sequence of binary digits ('0' and '1' and ending with a 'b'.number is decimal.'-' to indicate the number is negative. It may end with a 'd' to emphasize that theA decimal number is a sequence of decimal digits ('0' up to '9'. It may start with a

Different fragments of code are not allowed to overlap.

Examples:

A hexadecimal number can be written in 3 ways:

o

C-style: The number starts with '0x', followed by a sequence of

org

60h

hexadecimal digits ('0' up to '9' and 'A' up to 'F').

load

R0,

;put this instruction at address $

o

Pascal-style: The number starts with '$', followed by a sequence of

immediate load

hexadecimal digits ('0' up to '9' and 'A' up to 'F').

load

reg,number

load

reg,label

o

Assembler-style: The number is a sequence of hexadecimal digits ('0' up to

  • Assign the immediate value (number or address of label) to register reg.

'9' and 'A' up to 'F'), but it may not start with a letter. This sequence is

Examples:

load

R4,

followed by an 'h'. A number can always be made to start with a decimal

load

R9,Label_of_something

digit by prefixing the number with a '0', so ABh is written as 0ABh.

direct load

Spaces are not allowed within a number.

load

reg,[adr]

Assign the memory contents at address adr to register reg.

Remarks

Examples:- Address adr can be a number or a label.

load

R4,[8]

All identifiers (labels and mnemonics) and (hexadecimal) numbers are case-insensitive.

load

R9,[Label_of_something]

This means that load, Load, LOAD and lOaD are all the same and so are 0xAB, 0Xab

indirect load

and 0XAB.

load

reg1,[reg2]

Assign the memory contents of which register reg2 holds the address to register reg1.

This editor uses syntax-highlighting:

Example:

load

R4,[R8]

keywords:

load, store, addi

direct store

numbers:

-123, 0x10, 11001011b

comments:

;this is a comment

store

reg,[adr]

syntax errors:

12A3, -0x10, 1+

    • Put the value of register reg at memory location adr.

Address adr can be a number or a label.

Examples:

store

R4,[8]

store

R9,[Label_of_something]

data byte Mnemonics and operand combinations

store indirect store

reg1,[reg2]

db

dataitem_1, dataitem_2, ..., dataitem_n

  • Put the value of register reg1 at memory location of which register reg2 holds the address.

Puts data directly into the memory.

Example:

A dataitem can be either a number or a string.

store

R4,[R8]

An unlimited number of dataitems can be specified.

move

Examples:

db

move

reg1,reg

db

"Hello world",

  • Assign the value of register reg2 to register reg1.

origin

Example:

move

R4,R

org

adr

integer addition

The next code starts at address adr.

Address adr must be a number.

addi

reg1,reg2,reg