0% found this document useful (0 votes)
49 views14 pages

04 SIC XE Programming 2

This document provides examples of SIC and SIC/XE assembly language instructions for common operations like data movement, arithmetic, and looping. It shows how to load and store values, perform addition and subtraction, and use indexing to move data between arrays. Examples are given for loading constants, variables into registers, performing arithmetic operations, and using jump and compare instructions within a loop to iterate through an array.

Uploaded by

ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views14 pages

04 SIC XE Programming 2

This document provides examples of SIC and SIC/XE assembly language instructions for common operations like data movement, arithmetic, and looping. It shows how to load and store values, perform addition and subtraction, and use indexing to move data between arrays. Examples are given for loading constants, variables into registers, performing arithmetic operations, and using jump and compare instructions within a loop to iterate through an array.

Uploaded by

ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Chapter 2- System software and machine architecture

Lecture 2
SIC Programming Examples

 In this lecture we are going to study some examples of


SIC and SIC/XE instructions that implement some tasks,
namely, data movement operations, sample arithmetic
operations, and finally looping and indexing operations.

Chapter 1 Introduction 2
Data movement operations (SIC)

LDA FIVE LOAD CONSTANT 5 INTO A


STA ALPHA STORE A INTO ALPHA
LDCH CHARZ LOAD CHARACTER ‘Z’ INTO A

STCH C1 STORE A INTO C1


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

Chapter 1 Introduction 3
Data movement operations (SIC/XE)

LDA #5 LOAD VALUE 5 INTO A


STA ALPHA STORE A INTO ALPHA
LDCH #90 LOAD ASCII CODE OF ‘Z’ INTO A

STCH C1 STORE A INTO C1


ALPHA RESW 1 ONE-WORD VARIABLE
C1 RESB 1 ONE-BYTE VARIABLE

Chapter 1 Introduction 4
Sample arithmetic operations: ALPHA + INCR - 1 &
GAMMA + INCR – 1 (SIC)

LDA ALPHA LOAD ALPHA INTO A


ADD INCR ADD THE VALUE OF INCR
SUB ONE SUBTRACT 1
STA BETA STORE A INTO BETA
LDA GAMMA LOAD GAMMA INTO A
ADD INCR ADD THE VALUE OF INCR
SUB ONE SUBTRACT 1
STA DELTA STORE IN DELTA
ONE WORD 1 ONE-WORD CONSTANT
ALPHA RESW 1 ONE-WORD VARIABLE
Chapter 1 Introduction 5
Sample arithmetic operations: ALPHA + INCR - 1 &
GAMMA + INCR – 1 (SIC)

BETA RESW 1 ONE-WORD VARIABLE


GAMMA RESW 1 ONE-WORD VARIABLE
DELTA RESW 1 ONE-WORD VARIABLE
INCR RESW 1 ONE-WORD VARIABLE

Chapter 1 Introduction 6
Sample arithmetic operations: ALPHA + INCR - 1 &
GAMMA + INCR – 1 (SIC/XE)

LDS INCR LOAD INCR INTO S


LDA ALPHA LOAD ALPHA INTO A
ADDR S,A ADD THE VALUE OF INCR
SUB #1 SUBTRACT 1
STA BETA STORE BETA INTO A
LDA GAMMA LOAD GAMMA INTO A
ADDR S,A ADD THE VALUE OF INCR
SUB #1 SUBTRACT 1
STA DELTA STORE IN DELTA
ALPHA RESW 1 ONE-WORD VARIABLE
Chapter 1 Introduction 7
Sample arithmetic operations: ALPHA + INCR - 1 &
GAMMA + INCR – 1 (SIC/XE)

BETA RESW 1 ONE-WORD VARIABLE


GAMMA RESW 1 ONE-WORD VARIABLE
DELTA RESW 1 ONE-WORD VARIABLE
INCR RESW 1 ONE-WORD VARIABLE

Chapter 1 Introduction 8
Sample looping and indexing operations (SIC)

LDX ZERO SET INDEX REGISTER X TO 0

MOVECH LDCH STR1,X LOAD CHAR FROM STR1 INTO A

STCH STR2,X STORE A INTO STR2


TIX FOUR ADD 1 TO X THEN COMPARE TO 4

JLT MOVECH LOOP IF X IS LESS THAN 4


STR1 BYTE C’TEST’ 4-BYTE STRING CONSTANT
STR2 RESB 4 4-BYTE VARIABLE
ZERO WORD 0 ONE-WORD CONSTANT
FOUR WORD 4 ONE-WORD CONSTANT

Chapter 1 Introduction 9
Sample looping and indexing operations (SIC/XE)

LDT #4 SET REGISTER T TO 4


LDX #0 SET INDEX REGISTER X TO 0

MOVECH LDCH STR1,X LOAD CHAR FROM STR1 INTO A

STCH STR2,X STORE A INTO STR2


TIXR T ADD 1 TO X THEN COMPARE TO 4

JLT MOVECH LOOP IF INDEX IS LESS THAN 4


STR1 BYTE C’TEST’ 4-BYTE STRING CONSTANT
STR2 RESB 4 4-BYTE VARIABLE

Chapter 1 Introduction 10
Check point 2.1

Write a sequence of instructions to store the data value 8 in the


memory location ALPHA (for SIC and SIC/XE)

Chapter 1 Introduction 11
Answer

For SIC

Chapter 1 Introduction 12
Answer

For SIC/XE

Chapter 1 Introduction 13
Reading

Recommended book, sections, 1.3.3.

Chapter 1 Introduction 14

You might also like