System z Assembler - Ing. Wilhelm G. Spruth

Transcrição

System z Assembler - Ing. Wilhelm G. Spruth
System z Assembler
z/OS Lehrgang 2008/09
Prof. Dr.-Ing. Wilhelm G. Spruth
Teil 1
Einführung
7
1
3
4
4
3
Hauptspeicher aufgeteilt in
Blöcke (Rahmen)
zu je 4096 Bytes
Jedem Block wird vom Kernel
eine Speicherschutznummer
zwischen 0 ... 15 zugeordnet
3
3
1
7
7
1
0
0
0
00 ... 00
S/390 Speicherschutz
es 0146 ww6
wgs 06-99
Zuordnung von Rahmen zu
Prozessen
ar0310 ww6
wgs 11-96
Speicherschutz
Speicherschutzschlüssel
4 Bit
Programmstatuswort
20 Bit
12 Bit
4 Bit
Adresse
RÄ
Speicherschutzschnellspeicher mit
Hauptspeicherschlüsseln.
Je 1 Schlüssel (4 Bit)
pro 4096 Byte Block
(plus Steuerbits, z.B.
Referenzbit R und
Änderungsbit Ä)
ja
Vergleich
Speicherzugriff ok
nein
Programmunterbrechung
es 0147 ww6
wgs 06-99
Hauptspeicher aufgeteilt in
4 KByte Blöcke (Seitenrahmen)
mit unterschiedlichen
Speicherschutzschlüsseln
Puffer Überlauf
in benachbarten
4 KByte Block
C
7
7
3
3
3
4
4
4
A
A
0
0
0
0
Speicherschutzschüssel
Verhinderung des Puffer Überlaufs
(Buffer Overflow)
es 0263 ww6
wgs 07-04
Hauptspeicher direkt Adressierung
6502 Programming Model
7
0
Accumulator
A
X Register
X
Y Register
Y
PCH
PCL
Stack Pointer
S
Status
Register
N V B D I
Program
Counter
Z C
Carry
Zero
Interrupt.Disable
Decimal Mode
Break Command
Overflow
Negativ
an 0240 ww6
wgs 03-98
Assembler
Befehle
Maschinen
Befehle
Opcode
Operand
LDA
20 10
AD
10 20
ADC
20 11
6D
11 20
STA
20 12
8D
12 20
6502 Programm
In der Anfangszeit der Personal Computer
Entwicklung dominierte der 6502 Microprozessor,
besonders in den Apple 2, Commodore und Atari
Rechnern.
S/360 und 6502 sind besonders klar strukturierte
Architekturen (Gegenbeispiel Pentium). Kleine
Programme lassen sich überraschend leicht auch in
Maschinencode programmieren.
S/360 Memory Dump.
6502
Direkte Hauptspeicheradressierung
Der 6502 Mikroprozessor benutz die Little Endian
Adressierung.
Die direkte und die indirekte
Hauptspeicheraddressierungsart wird auf Grund von
Relocate - Schwierigkeiten nur noch selten
verwendet. Bei der S/390 und zSeries Architektur
fehlt sie fast ganz.
(Ausnahme: die untersten 4 Kbyte des S/390
Hauptspeichers, bzw. die untersten 8 Kbyte
des´System z Hauptspeichers - Prefix Area ).
ar0311 ww6
wgs 07-02
S/360 RR Instruction
The instruction is 16 bits or one halfword in length.
The first byte contains the opcode, and the second
byte contains the two operands, both of which are
registers
An RR Instruction example is 1A34 .
1A is the operation code for the Add Register
instruction. The first operand is R3. The second
operand is R4.
When this instruction is executed, the contents of
R4 would be added to the contents of R3 and the
sum would be placed in R3, replacing the first
operand.
RR Maschinenbefehl Beispiel
z/Architecture
Principles of Operation
http://www-03.ibm.com/
servers/eserver/zseries/zose/bkserv/r5pdf/zarchpops.html
SA22-7832-00
8
4
4 Bit
OP
R1 R2
RR Format, 16 Bit
8
OP
4
4
R1 X2
4
12 Bit
B2
D2
RX Format, 32 Bit
8
8
4
12
4
12 Bit
OP
L
B1
D1
B2
D2
SS Format, 48 Bit
Beispiele für
S/360 Maschinenbefehlsformate
Die allermeisten /360 Maschinenbefehle sind zwei-Adress
Befehle.
There are 3 possible S/390 instruction lengths,
1, 2 or 3 halfwords. They are:
• 1 halfword instructions have no storage operands
• 2 halfword instructions have one storage operand
• 3 halfword instructions have 2 storage operands
Types of Operands
Most instructions have 2 operands, but some have 0, 1, 2
or 3. The different types of operands are:
•Registers, specified by a register number
•Main storage location, specified by a base displacement
address (BDDD)
•Main storage locations, specified with an indexed base
displacement address (XBDDD)
•A single byte of immediate data, contained within the
instruction itself (I).
Most instructions have two operands. In most
instructions, the result of the operations replaces
the first operand. For example, Add has two
operands.
The Add instruction (A) fetches both operands, adds
them together and replaces the first operand with
the sum.
Effektive Adresse
Effektive Adresse = EA
In einfachen Fällen, z.B. beim Toy Rechner und beim
6502 Rechner sind Effektive Adressen mit den realen
Adressen identisch, mit denen auf den
Hauptspeicher zugegriffen wird.
In der Regel entstehen Effektive Adressen als
Ergebnis einer Adressenrechnung, die während der
Ausführung eines Befehls vorgenommen wird.
Zusätzlich können Effektive Adressen mit Hilfe einer
"Virtuellen Adressenumsetzung " in reale
Hauptspeicheradressen umgesetzt werden (siehe
Teil 5). Wenn dies geschieht, bezeichnet man die
effektive Adresse häufig als virtuelle Adresse und
das Ergebnis der virtuellen Adressumsetzung als
reale Adresse.)
Operand 1
4 Bit
Operand 2
4 + 4 + 12 BitBit
S/360 RX Maschinenbefehl
S/390 RX Format Maschinenbefehl „Load“
L R1, 4,(R3,R2)
Immediate Operand
Der Operand steht nicht in einem Register oder im
Hauptspeicher, sonder im Operandenfeld des
Maschinenbefehls.
ar0312 ww6
wgs 07-02
The Move Immediate (MVI) instruction uses the SI format. It
moves its immediate operand, the one byte operand
contained within the instruction itself, to the first operand
location.
For example:
MVI
FLD3,C’*'
This instruction moves an asterisk to FLD3, a one-byte field
in main storage.
S/390 Move immediate Machinenbefehl
MVI
4(R1), 7
Kleine Konstanten
Kleine numerische Werte in ein Register laden:
The Insert Character (IC) instruction transfers a single byte
of data from main storage to the low order 8 bit positions of
the register specified. The high order 24 bits of the register
are unchanged.
For example: IC
R5,BYTE1
S/390 Alternative: Der LA - Befehl,
LA
R4, 9
(4 Byte Länge)
kann Werte bis max. 12 Bit in ein Register laden.
The two formats of SS instructions
The first format has single length specification, which
applies to both of its operands. The second has a separate
length specified for each operand
When there are two lengths, each is specified as a nibble,
and can contain values from 0 – 15. when there is a single
length specification it is a byte in length, and can contain
values from 0 – 255.
All lengths in machine instructions are coded as 1 less
than the actual length. This is because a zero length
dosen’t make sense for an operation, and so in order to
provide maximum facility, a machine length specification of
0, represents a real length of 1, 1 represents 2, and so on.
The two SS formats are shown on the nexttwo foils. The
instructions are 48 bits or 3 halfwords in length. The first
byte is the opcode. The next byte is the length or lengths.
This is followed by operand one and operand two, both
specified in base displacement format with a length of 16
Bit each..
Move (MVC) Instruction
moves the second operand
into the first Operand location
S/390 Maschinenbefehl
Move Character
MVC 7(3,R1), 6(R2)
RXE Maschinenbefehlsformat
Die ursprünglichen /360 Maschinenbefehle hatten
alle ein 8 Bit Op Code Feld. Von den 256 möglichen
Op Codes waren etwa 160 belegt.
Vor allem mit der 64 Bit System z Erweiterung wuchs
die Anzahl der Maschinenbefehle
•
•
•
•
•
64 Bit Befehle
ASCII Darstellung
IEEE Gleitkomma Format
Dezimales Gleitkomma Format
Kryptographische Maschinenbefehle
Deshalb zusätzliches 8 Bit Op Code Feld. Derzeitig
etwa 800 Maschinenbefehle.
There are 16 general purpose registers (GPRs),
numbered from 0-15. They are referred to with a
prefix of R (R0, R1, R2…. R15).
S/390 GPRs are 32 bits in length and can hold
fixed-point values between -2, 147, 483, 648, and
+2, 147, 483, 647.
System z Registers are 64 Bit in length.
GPRs are used as:
• Part of the address for all storage operands
• As accumulators and work areas in performing
fixed-point arithmetic
Register
Number
Control
Register
Access
Register
General
Register
Floating Point
Register
32 bits
32 bits
32 bits
64 bits
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
S/390 Control-, Access, General, and
Floating-Point Register
es 0142 ww97
wgs 08-00
Register
Number
Control
Register
Access
Register
General
Register
Floating Point
Register
64 bits
32 bits
64 bits
64 bits
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Programm Status Wort
Status Reg. Befehlszähler
zSeries Control-, Access, General, and Floating-Point
Register
es 0158 ww97
wgs 04-02
Jedes Object Module hat seinen eigenen Adressenraum,
der mit der hexadezimalen Adresse 00...00 anfängt.
Beispiel
Vier
Object Modules
vor dem
Relocate und
Linking
Beispiel
Vier
Object Modules
nach dem
Relocate und
Linking
Interne Struktur eines
Objekt Modules
• Das Relocation dictionary besagt, welche Adressen
geändert werden müssen.
• Der external Reference Table weist auf Aufrufe
außerhalb des Modules hin.
• Der Entry point Table enthält die Adressen von
Befelhen, die von außerhalb des Modules aufgerufen
werden können.
Weiterführende Information
zum Thema Assembler
IBM High Level Assembler for MVS & VM & VSE Release 2
Presentation. Download from:
http://www.redbooks.ibm.com/abstracts/sg243910.html?Open
Michael D. Kudlick: Assembly Language Programming for the IBM
System 370 and Compatible Computers. C. Brown Publishers, 1988.
G. Amdahl, G. Blaauw, F. Brooks: Architecture of the IBM
System/360. IBM J. Res. Devel. 8 (2), 87-101 (1964).
http://www.research.ibm.com/journal/rd/441/amdahl.pdf
search www.amazon.com for „Assembler“ und „/370“. Die meisten
Titel erschienen vor 1990.
Herunterladen des offiziellen IBM Reference Manuals
High Level Assembler for MVS . &VM &VSE Language Reference,
IBM Form No. SC26-4940-02
http://www.elink.ibmlink.ibm.com/public/applications/publications/c
gibin/pbi.cgi?CTY=US&FNC=SRX&PBL=SC26-4940-02
An assembler tutorial is available on the Web under
http://www.wiu.edu/users/mflll/cs310/head.html
Interessante Assembler Hinweise sind zu finden unter
http://www.planetmvs.com/hlasm/s390faq.html#inetc
The following application was created to allow a BMS source file to
be displayed under TSO, exactly in the same way as it will appear in
CICS.
http://www.mainframeweek.com/journals/articles/0075/Display+BMS
+under+TSO
http://www.dmoz.org/Computers/Programming/Languages/Assembl
y/370/
http://www.ntecs.de/old-hp/uu9r/lang/html/assembler.en.html
http://www.google.com/Top/Computers/Programming/Languages/A
ssembly/370/
http://www2.latech.edu/~acm/helloworld/asm370.html
http://www.cbttape.org/~jmorrison/s370asm/html/tut-REFSUM001.html

Documentos relacionados