Docsity

Assembler - Computer Organization and Assembly Language - Lecture Slides, Slides of Assembly Language Programming

Partial preview of the text

Download Assembler - Computer Organization and Assembly Language - Lecture Slides and more Slides Assembly Language Programming in PDF only on Docsity!

Computer Organization &

Assembly Languages

Assembler

Overview

 SIC Machine Architecture

 SIC/XE Machine Architecture

 Design and Implementation of Assembler

Source

Program

Assembler

Object

Code

Loader

Executable

Code

Linker

SIC, SIC/XE Program

 The Simplified Instructional Computer (SIC)

 Memory

 Memory consists of 8-bit bytes

 Any 3 consecutive bytes form a word (24 bits)

 Total of 32768 (2^15 ) bytes in the computer memory

 Registers

 Five 24-bits registers

SIC Machine Architecture

SIC Machine Architecture

 Data Formats

 Integers are stored as 24-bit binary number  2’s complement representation for negative values  Characters are stored using 8-bit ASCII codes  No floating-point hardware on the standard version of SIC

 Instruction Formats

 Standard version of SIC

opcode x address

Mode Indication Target address calculation

Direct x=0 TA=address

Indexed x=1 TA=address+(X)

(X): the contents of register XDocsity.com

SIC Programming Example

LDA FIVE

STA ALPHA

LDCH CHARZ

STCH C

ALPHA RESW 1 one-word variable

FIVE WORD 5 one-word constant

CHARZ BYTE C’Z’ one-byte constant

C1 RESB 1 one-byte variable

SIC Programming Example

LDX ZERO initialize index register to 0

MOVECH LDCH STR1,X load char from STR1 to reg A

STCH STR2,X

TIX ELEVEN add 1 to index, compare to 11

JLT MOVECH loop if ―less than‖

STR1 BYTE C’TEST STRING’

STR2 RESB 11

ZERO WORD 0

ELEVEN WORD 11

SIC Programming Example

INLOOP TD INDEV test input device

JEQ INLOOP loop until device is ready

RD INDEV read one byte into register A

STCH DATA

OUTLP TD OUTDEV test output device

JEQ OUTLP loop until device is ready

LDCH DATA

WD OUTDEV write one byte to output device

INDEV BYTE X’F1’ input device number

OUTDEV BYTE X’05’ output device number

DATA RESB 1

Overview

 SIC Machine Architecture

 SIC/XE Machine Architecture

 Design and Implementation of Assembler

Source

Program

Assembler

Object

Code

Loader

Executable

Code

Linker

SIC, SIC/XE Program

SIC/XE Machine Architecture

 Instruction Formats

op

op r1 r

Format 1 (1 byte)

Format 2 (2 bytes)

Formats 1 and 2 are instructions that do not reference memory at all

Format 3 (3 bytes)^ op^ n^ i^ x^ b^ p^ e^ disp

Format 4 (4 bytes) op n i x b p e address

SIC/XE Machine Architecture

 Addressing modes

 Base relative (n=1, i=1, b=1, p=0)

 Program-counter relative (n=1, i=1, b=0, p=1)

 Direct (n=1, i=1, b=0, p=0)

 Immediate (n=0, i=1, x=0)

 Indirect (n=1, i=0, x=0)

 Indexing (both n & i = 0 or 1, x=1)

 Extended (e=1 for format 4, e=0 for format 3)

SIC/XE Machine Architecture

 Direct Addressing Mode

n i x b p e

opcode 1 1 0 0 disp

n=1, i=1, b=0, p=0, TA=disp (0disp 4095)

n i x b p e

opcode 1 1 1 0 0 disp

n=1, i=1, b=0, p=0, TA=(X)+disp

(with index addressing mode)

SIC/XE Machine Architecture

 Immediate Addressing Mode

n i x b p e

opcode 0 1 0 disp

n=0, i=1, x=0, operand=disp

 Indirect Addressing Mode

n i x b p e

opcode 1 0 0 disp

n=1, i=0, x=0, TA=(disp)

SIC/XE Machine Architecture

 Addressing Modes Summary

SIC/XE Machine Architecture

 Instruction Format