| English | 의미 |
|---|---|
| assembler/əˈsemblə/ | 어셈블러 |
| mnemonic/nɪˈmɒnɪk/ | mnemonic |
| instruction set/ɪnˈstrʌkʃn set/ | 명령어 집합 |
| machine code/məˈʃiːn kəʊd/ | 머신 코드 |
| assembly language/əˈsemblɪ ˈlæŋɡwɪdʒ/ | 어셈블리 언어 |
| operand/ˈɒpərænd/ | 연산자 |
| opcode/ˈɒpkəʊd/ | opcodes |
| symbol table/ˈsɪmbl ˈteɪbl/ | 기호표 |
| label/ˈleɪbl/ | 라벨 |
| forward references/ˈfɔːwəd ˈrefrənsɪz/ | 전방 참조 |
| addressing mode/əˈdresɪŋ məʊd/ | 주소 지정 방식 |
| immediate addressing/ɪˈmiːdɪət əˈdresɪŋ/ | 즉각 주소 지정 |
| direct addressing/daɪˈrekt əˈdresɪŋ/ | 직접 주소 지정 |
| indirect addressing/ɪndaɪˈrekt əˈdresɪŋ/ | 간접 주소 지정 |
| indexed addressing/ˈɪndekst əˈdresɪŋ/ | 인덱드 주소 지정 |
| relative addressing/ˈrelətɪv əˈdresɪŋ/ | 상대 주소 지정 |
Thirty-one instructions on a row of switches
- In 1949 the EDSAC computer in Cambridge started up from 31 instructions set on switches, written by David Wheeler and called the "initial orders".
- Their whole job was to read letters such as A and S from paper tape and turn them into the numbers the machine actually understood: the first assembler 汇编器.
- Programmers have written mnemonics instead of bit patterns ever since, and the exam's own instruction set is a direct descendant.
- This lesson is about that translation, tracing a program by hand, and the five ways an instruction can say where its data is.
Machine code and assembly language
- The processor runs machine code 机器码: bit patterns, specific to one architecture, each one an operation code and an operand.
- Assembly language 汇编语言 is the readable form. Each instruction is written with a mnemonic 助记符 such as
LDD,ADDorJMP, and each assembly instruction becomes exactly one machine-code instruction. - The assembler translates it. The relationship is one to one, which is what makes assembly different from a high-level language, where one statement becomes many instructions.

Each mnemonic becomes one opcode; each symbolic address becomes a number
어셈블리 언어는:
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
어셈블리는 마넬닉을 사용하며 기계어와 1:1로 매핑되며, 어셈블러가 이를 번역합니다.
The two-pass assembler
- Pass 1 reads the source and builds a symbol table 符号表: every time a label 标签 such as
LOOP:appears, its address is recorded. No code is produced. - Pass 2 reads the source again and generates the code, replacing each mnemonic by its opcode 操作码 and each symbolic address by the number from the symbol table.
- Two passes are needed because of forward references 前向引用:
JMP LOOPmay appear before the lineLOOP:has been seen, so its address is not known on the first pass.
투 패스 어셈블러의 1차 pass는 무엇을 합니까?
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
1차 pass는 각 라벨이 있는 곳(심볼 테이블)을 기록하고, 2차 pass는 표를 사용하여 라벨 참조를 해결하며 코드를 생성합니다.
투 패스 어셈블러의 작업을 순서대로 배치하십시오.
난이도 3/5 · 200 코인 + 오늘 첫 완료 시 소액 보너스
1차 pass가 모든 라벨을 먼저 찾으므로 2차 pass는 나 나중에 정의된 라벨로 점프하는 것까지도 해결할 수 있습니다.
왜 어셈블러는 두 번의 pass가 필요합니까?
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
점프가 소스 코드에서 나 나중에 나타나는 라벨을 타겟으로 할 수 있습니다; 1차 pass가 모든 라벨을 먼저 찾으므로 2차 pass가 이를 해결할 수 있습니다.
Worked example: applying the two passes
- The program starts at address 100.
100 LDD COUNT
101 LOOP: DEC ACC
102 CMP #0
103 JPN LOOP
104 END
105 COUNT: 5
- Pass 1 counts the address of each line and records the labels:
LOOP= 101,COUNT= 105. Nothing else is written. - Pass 2 translates line by line.
LDD COUNTbecomes the opcode forLDDwith operand 操作数 105;JPN LOOPbecomes the opcode forJPNwith operand 101. Without pass 1, the first line could not have been translated.
투 패스 어셈블러의 작동 원리
단계별로 확인하십시오. 어셈블러는 코드를 두 번 읽습니다: 1차 pass는 각 라벨의 위치만 찾아내므로 2차 pass에서 주소를 채울 수 있으며, 이것이 나중에 정의된 라벨로 점프하는Still 작동하는 방법입니다.
작업 예제에서, 1차 pass는 라벨 LOOP를 심볼 테이블에 주소 ____로 기록합니다.
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
프로그램이 100에서 시작하므로, 두 번째 줄 LOOP: DEC ACC은 101을 차지합니다. COUNT는 여섯 번째 줄에 있어 105입니다.
The instruction set
- Cambridge's instruction set 指令集 has one general-purpose register, the accumulator ACC, and an index register IX. An operand
#nis denary,Bnbinary,&nhexadecimal, and<address>a location number or a label. - Data movement:
LDM #n,LDD <address>,LDI <address>,LDX <address>,LDR #n,MOV IX,STO <address>. Input and output:IN,OUT. - Arithmetic:
ADD,SUB,INC,DEC. Compare:CMP,CMI. Jumps:JMPunconditional,JPEandJPNconditional. Bit manipulation:AND,OR,XOR,LSL,LSR. ThenEND. - "Instructions are grouped": name the groups and give one instruction from each.
다음 중指令집의 그룹은 무엇입니까? 모든 적용 가능한 것을 선택하십시오.
난이도 2/5 · 140 코인 + 오늘 첫 완료 시 소액 보너스
데이터 이동, 입출력, 산술, 비교, 조건부 및 비조건부 점프, 비트 조작. 스프래드시트는 이 수준보다 훨씬 높은 응용 소프트웨어입니다.
Worked example: tracing a program
- Draw a table with a column for the ACC and for every memory location the program uses, then update it line by line until
END.
100 LDM #0
101 STO TOTAL
102 LDD TOTAL
103 ADD #5
104 STO TOTAL
105 LDD COUNT
106 DEC ACC
107 STO COUNT
108 CMP #0
109 JPN 102
110 END
111 TOTAL: 0
112 COUNT: 3
- Pass 1 of the loop: ACC 0 → 5 (TOTAL = 5), COUNT 3 → 2, compare not equal, jump. Pass 2: TOTAL = 10, COUNT = 1, jump. Pass 3: TOTAL = 15, COUNT = 0, compare equal, no jump,
END. - Final values: TOTAL = 15, COUNT = 0, ACC = 0. Write a new row only when a value changes, and never skip the compare.
추적된 프로그램에서 END에 도달했을 때 TOTAL의 값은 무엇입니까?
난이도 2/5 · 140 코인 + 오늘 첫 완료 시 소액 보너스
루프는 세 번의 반복마다 각각 한 번씩 TOTAL에 5를 더합니다: 5, 10, 15.
Addressing modes
- The addressing mode 寻址方式 says how the processor finds the operand.
| Mode | Where the operand is | Example |
|---|---|---|
| immediate addressing 立即寻址 | the value is in the instruction itself | LDM #10 loads 10 |
| direct addressing 直接寻址 | the instruction holds an address; use the value stored there | LDD 200 loads the contents of 200 |
| indirect addressing 间接寻址 | the address holds another address, which holds the data | LDI 200 |
| indexed addressing 变址寻址 | effective address = the address given + the index register | LDX 200 with IX |
| relative addressing 相对寻址 | the address is an offset from the current instruction | jumps |

The same operand field, four different meanings
즉각 주소 지정(예: LDM #10)에서 피연산자는:
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
즉각 주소 지정은 명령어에 있는 상수값(여기서는 10)을 사용합니다.
각 주소 지정 방식을 의미와 연결하십시오.
난이도 2/5 · 140 코인 + 오늘 첫 완료 시 소액 보너스
즉각 = 값; 직접 = 값의 주소; 간접 = 주소의 주소; 인덱스 = 베이스 + 인덱스.
Worked example: one operand, four answers
- Memory: location 200 holds 300, location 300 holds 7, location 202 holds 9. The index register IX holds 2.
LDM #200puts 200 in the ACC: immediate, the number itself.LDD 200puts 300 in the ACC: direct, the contents of 200.LDI 200puts 7 in the ACC: indirect, the contents of the address found at 200.LDX 200adds IX to 200 and loads the contents of 202: 9. Same operand written four ways, four different values.
Why indexed addressing exists
- An array is a run of consecutive locations.
LDX 200with IX = 0, 1, 2, … reads element 0, 1, 2, … without changing the instruction. - The loop pattern:
LDR #0to zero the index,LDX ARRAYto fetch an element, do something,INC IX, compare with the length,JPNback. - Direct addressing would need a separate instruction for every element; indexed addressing needs one.
인덱스 주소 지정 방식이 가장 유용한 상황은:
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
유효 주소는 베이스 주소 + 인덱스 레지스터이므로, 인덱스를 증가시키면 배열을 순회하게 된다.
Compare and jump
CMP #norCMP <address>compares the ACC with a value and sets the flag. It does not change the ACC.JPE <address>jumps if the last compare found the values equal;JPN <address>jumps if they were not equal;JMP <address>always jumps.- An
IFin a high-level language becomes aCMPfollowed by a conditional jump; a loop becomes a compare and a jump back to a label.
CMP #0가 어큐뮰레이터에 저장된 값을 변경한다.
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
비교(CMP) 지시어는 다음 조건부 점프가 읽는 플래그만 설정한다. ACC는 변하지 않으므로 trace에서 CMP 줄에 새로운 ACC 값이 표시되지 않는다.
Marks that slip away
LDM #10loads the number 10;LDD 10loads the contents of location 10. The#is the whole difference.#is denary,Bis binary,&is hexadecimal.AND &0FandAND B00001111are the same mask;AND #15is too.CMPleaves the ACC alone; it only sets the flag.JPNjumps when the values are not equal.- Pass 1 of the assembler writes no code. Its output is the symbol table, and forward references are the reason it exists.
You've got it
- machine code is bit patterns; assembly is mnemonics, one to one, translated by an assembler
- two passes: pass 1 builds the symbol table of label addresses, pass 2 generates code; needed for forward references
- trace with a table of ACC and every location, one row per change; CMP sets the flag, JPE/JPN read it
- addressing: immediate
#nthe value · direct the contents of the address · indirect the address of the address · indexed address + IX (arrays) · relative an offset