The architecture styles
ตามเอกสาร IMD2-Instruction-Set-Styles.pdf มีดังนี้
- Accumulator
- Memory-memory
- Stack
- Load-store
ถ้าเราต้องการเขียน a = b + c จะสามารถเขียนตามแต่ละ architecture styles ได้ดังนี้
Accumulator Architectures
- Instruction set
add A, sub A, mult A, div A, . . .
load A, store A - Example
load AddressB # Acc = Memory[AddressB], or Acc = B
add AddressC # Acc = B + Memory[AddressC],or Acc = B + C
store AddressA # Memory[AddressA] = Acc, or A = B + Cจะเห็นว่า แต่ละคำสั่งมีแค่ OP(load,add,store) + Memory Address(A,B,C)โดยทุกการกระทำ จะถูกทำผ่าน ตัว Acc เพียงตัวเดียว
สมมติ (แค่สมมติ) เขียน asm ปกติ แต่มี register แค่ตัวเดียว ประมาณนั้น
Memory-Memory Architectures
- Instruction set
(3 operands) add A, B, C sub A, B, C mul A, B, C - Example
add AddressA , AddressB , AddressCจะเห็นว่า คำสั่งถ้าทำแบบ memory-memory แล้ว จะสั่งผ่าน MemoryAddress โดยตรงเลย
Load-Store Architectures
- Instruction set
add R1, R2, R3 sub R1, R2, R3 mul R1, R2, R3
load R1, R4 store R1, R4
- Example
load R1, AddressC
load R2, AddressB
add R3, R1, R2
store R3 , AddressAจะเห็นว่า memory address จะถูก load ใส่ใน register ก่อน
จากนั้นค่อย ทำการ บวก ผ่าน register หลังจากนั้นค่อย store ค่าใส่ไปยัง Memory Address (A)
Stack Instructions
- Instruction set
add, sub, mult, div, . . .
push A , pop A - Example
push AddressC # Top=Top+4;Stack[Top]=Memory[AddressC]
push AddressB # Top=Top+4;Stack[Top]=Memory[AddressB]
add # Stack[Top–4]=Stack[Top] + Stack[Top–4];Top=Top–4;
pop AddressA # Memory[AddressA]=Stack[Top];
# Top=Top–4;
จะเห็นว่า คำสั่งจะถูกทำผ่าน stack
การ add (บวก) ก็จะเข้าไปทำในตัวที่ stack pointer ชื้อยู่ กับตัวด้านล่าง stack pointer
แล้วนำค่ามาเก็บ เป็นตัวที่ stack pointer ชื้อันใหม่







เรายังไม่มีความรู้อะไรเลยอ่ะ – - เลยอ่านไม่ค่อยรู้เรื่องเลย
Leave your response!