Overview

Assembly language is a low-level programming language that provides a direct mapping to machine code instructions. It serves as an intermediate step between high-level programming languages and machine code (sequences of 1's and 0's).

High-Level Language → Assembly Language → Machine Language (Binary)

Importance in Modern Programming

ACSL Assembly Language

ACSL uses its own simplified assembly language to teach core concepts without the complexity of real-world assembly languages. While simplified, it maintains the fundamental concepts common to all assembly languages.

Key Concepts

Basic Program Structure

Every ACSL assembly program follows these key rules:

Program Line Structure

Each line has three parts:

LABEL OPCODE LOC

Understanding Each Part

Instruction Reference Chart

OPCODE DESCRIPTION
LOAD*Puts value from LOC into ACC
STORESaves ACC value to LOC
ADD*Adds LOC to ACC and stores result in ACC (result ≤ 999,999)
SUB*Subtracts LOC from ACC and stores result in ACC (result ≤ 999,999)
MULT*Multiplies ACC by LOC and stores result in ACC (result ≤ 999,999)
DIV*Divides ACC by LOC and stores whole number result in ACC
BGJump to LOC if ACC > 0
BEJump to LOC if ACC = 0
BLJump to LOC if ACC < 0
BUJump to LOC unconditionally
READInput number into LOC
PRINTOutput value in LOC
DCDefine constant; assigns LOC to LABEL (requires LABEL)
ENDStop program

* Instructions marked with asterisk can use immediate data

Examples

Example: Tracing a short program

What is printed when the following program is executed?

XDC20
LOADX
DIV=6
MULT=5
SUBX
STOREY
PRINTY
END

Trace the accumulator line by line:

  1. X DC 20 defines the constant X = 20. ACC is still 0.
  2. LOAD X copies 20 into ACC.
  3. DIV =6 divides ACC by the immediate value 6. 20 ÷ 6 = 3.33..., and only the whole number is kept, so ACC = 3.
  4. MULT =5 gives ACC = 3 × 5 = 15.
  5. SUB X subtracts X: 15 - 20 = -5. ACC = -5.
  6. STORE Y saves -5 into Y.
  7. PRINT Y outputs -5.

Output: -5

Practice Problems

Problem 1 Junior

What is printed when the following program is executed?

NDC47
LOADN
DIV=7
STOREP
MULT=8
ADDN
DIV=-30
ADDP
STORES
PRINTS
END

Problem 2 Intermediate

What is output after this program is executed?

ADC36
LOADA
DIV=8
STOREB
MULT=10
STOREC
LOADB
SUBA
STORED
DIV=9
MULT=7
ADDB
STOREE
SUBA
DIV=6
STOREG
PRINTG
END

Problem 3 Senior

What is the sum of the outputs of the following assembly language program after it is executed?

ADC4213
BDC16
TOPLOADA
DIVB
STOREC
BEDOWN
LOADC
MULTB
STOREE
LOADA
SUBE
STOREF
PRINTF
LOADC
STOREA
BUTOP
DOWNPRINTA
END