8051
AVR
EZLab
PIC
80C196KC
DSP
ARM
VHDL
ũθ콺
κ౸
Battle κ
κȸ
޸շκ
Embeded Linux
HW/SW
RTOS
 
 

 

2. 196

 

II. 196 Assember

II-II. 196

II-II-5. Stack subroutine system

196KC stack/subroutine call/system ̴.

mnemonic

byte

state

operand

flags

1st

2nd

Z

N

C

V

VT

ST

I

PSE

PUSH

1

6/8+CEA

waop










POP

1

8/11+CEA


waop









PUSHF

1

6/8



0

0

0

0

0

0

0

0

POPF

1

7/10











PUSHA

1

12/18



0

0

0

0

0

0

0

0

POPA

1

12/18











LCALL

3

11/13

disp-high

disp-low









SCALL

2

11/13

disp










RET

1

11/14











EI

1

2

enable interrupt (I=1)







1


DI

1

2

disable interrupt (I=0)







0


EPTS


2

enable PTS (PSE=1)








1

DPTS


2

disable PTS (PSE=0)








0

TRAP

1

16/18

(SP)IP, IP2010H









IDLPD

2

8/25

baop


0

0

0

0

0

0

0

0

RST

1

15

IP2080H

0

0

0

0

0

0

0

0

 

< ǥ ִ operand ǹ>

a/b : 'a' stack memory ִ , 'b' stack ܺ memory ִ ̴.

II-II-5-1. Stack

α׷ ־ stack data ϴ Ҷ ִ. ̹ ˰ ִ ó stack ߿  data ó Ǿִ.(LIFO - Last In First Out, or FILO) ݴ Queue ̴.(FIFO - First In First Out) Stack stack (TOP) Ű pointer (SP - Stack Pointer) data ִ Stack Ǿ ִ.

Stack data ִ push ϸ, data pop̶ Ѵ. 196 16bit (word) data ְ ִ. data , SP ϰ ǰ, data SP ϰ ȴ. 196 SP ڰ Ͽ stack ġ ְ ش. memory Ȥ ܺ memory ִ. ܺ memory stack ϸ push pop ϴ ð ɸ ȴ.

                      

(1) PUSH/POP (Push/Pop word)

word operand stack push/pop ϴ ̴.

> PUSH <word operand> ; SPSP-2, [SP]<word operand>

POP <word operand> ; <word operand>[SP], SPSP+2

ex) LD SP, #0F0H ; register stack

LD 50H, #1234H --------

PUSH 50H

CLR 50H --------

: : :

POP 50H --------

ɱ ɱ ɱ

addr

low byte

high byte


SP

F0H

00H


50H

34H

12H









00F0H



 

addr

low byte

high byte


SP

EEH

00H


50H

00H

00H


:

:

:

00EEH

34H

12H


00F0H



 

addr

low byte

high byte


SP

F0H

00H


50H

34H

12H






00EEH

34H

12H

00F0H



 

Stack ٸ Ư¡ .

stack memory address address Ŀ ȴ. POP SP 2 Ű, PUSH SP 2 ҽŲ.

PUSH/POP ׻ word ̹Ƿ, word operand ؾ Ѵ.

PUSH/POP data ִ memory ġ SP ϰ ֱ , LD 50H, 2[SP] Ͽ, SP ̿ stack ִ data access ִ.

(2) PUSHF/POPF (Push/Pop Flags)

̴ PSW(Program Status Word) push/pop ϴ ̴. PSW pushϸ PSW 0 Ǿ interrupt disableǰ, PSW interrupt mask push ȴ. ̳ PSW ִ Ŀ subroutine call , subroutine PSW ִ ɵ ִٸ, PSW ϱ ؼ routine ó ̰ ؾ Ѵ.

> PUSHF ; SPSP-2, [SP]PSW, PSW0(interrupt disable)

POPF ; PSW[SP], SPSP+2

(3) PUSHA/POPA (Push/Pop All)

8096 PUSHF/POPF Ͽ, 80196 interrupt mask1 WSR push/popϴ ̴. PSW interrupt1 push/pop ϰ Ǹ, push PSW 0 ȴ.

> PUSHA ; SPSP-2, [SP]PSW/INT_MASK, PSW0(interrupt disable)

; SPSP-2, [SP]INT_MASK1/WSR, INT_MASK10

POPA ; INT_MASK1/WSR[SP], SPSP+2

; PSW/INT_MASK[SP], SPSP+2

II-II-5-2. Subroutine call

Subroutine α׷Ӱ ̸ Ư α׷ block̴. Ư Ѵٴ, string LCD ϴ block ̴. ̷ subroutine α׷ κп ־ Ѵ. subroutine бʹ ٸٴ ؾ Ѵ. subroutine ѹ ϰ , ġ ؾ ϹǷ, б(jump)ʹ ٸ ȴ. , subroutine call ɿ ҷ, return ɿ ġ ϰ ȴ. CALL RET ġ ϰ ǵư ؼ stack Ѵ.

                                   

α׷ CALL ϰ Ǹ ŭ ġ Jumpϰ ȴ. ׷ ⼭ jumpʹ ޸ jump Բ, CALL address (, IP) stack Ѵ. jump subroutine return main ϰ Ǵµ, ̶ return stack IP popϿ IP ְ ȴ. ̷ ϸ, call ٷ ִ. , CALL RET ϸ .( Ͼ )

CALL XXX ; SPSP-2, [SP]IP, IPIP+displacement(jump)

RET ; IP[SP], SPSP+2

196KC JUMP LCALL SCALL ִ.

(1) LCALL (Long Call)

ġ -32768~32767 ġ(196KC address space) ִ subroutine call Ѵ.

> LCALL <displacement word> ; ġ -32768~+32767 ġ branch

(2) SCALL (Short Call)

ġ -1024~+1024(1K) ġ ִ subroutine call Ѵ. SJMP , LCALL code 1byte ۱ 1K ̳ subroutine call ϸ memory ִ.

> SCALL <displacement 11bit>

note> ASM96 CALL ϸ, assembler ڵ SCALL/LCALL ȯش. JMP label ϸ ȴ.

subroutine stack RET ݵ push data popؾ Ѵ. ׷ ġ ̴.

II-II-5-3. System

(1) EI/DI (Enable/Disable Interrupts)

maskable interrupt enable/disable Ѵ.

> EI ; I flag=1

DI ; I flag=0

(2) EPTS/DPTS (Enable/Disble PTSs)

PTS(Peripheral Transaction Server) enable/disable Ѵ.

> EPTS ; PSE flag=1

DPTS ; PSE flag=0

(3) TRAP

interrupt call , memory address 2010H jumpѴ. .

SPSP-2, (SP)IP, IP(2010H)

program debugging ϸ ȴ.

(4) RST (software Reset)

system resetϴ ̴. , PSW=0, IP 2080H ʱȭǸ, SFR ʱⰪ settingȴ. hardware reset ȿ ִ.

(5) IDLPD

CPU idle/power down mode ϰų resetŲ.

> IDLPD #key(byte)

key

1

idle mode

2

power down mode

ٸ

reset

 

        : http://www.postech.ac.kr/group/poweron/ - lectures/Micro processor, controller, Ƹ

                          : Micro controller 80196 ʺ -

 

<Programming Exercise>

1. α׷ ۼ϶.

(1) byte register 20H ִ 2 16 ASCII code ٲپ byte register 30H, 31H ϴ α׷.

)

ASCII

Hex

ASCII

Hex

2FH

/

39H

9

30H

0

3AH

:

31H

1

40H

@

32H

2

41H

A

33H

3

42H

B

34H

4

43H

C

35H

5

44H

D

36H

6

45H

E

37H

7

46H

F

38H

8

47H

G

 

2. ĭ ä.

SP

20H

21H

22H

23H

24H

25H

stack ([SP])

low

high

low

high

LD SP, #7EE0H











LD 50H, #0











ST 50H, [SP]











LD 20H, #1234H











LD 22H, #5678H











LD 24H, #0A0BH











PUSH 20H











PUSH 22H











PUSH 24H











XCH 20H, 22H











XCH 20H, 24H











POP 24H











POP 22H











POP 20H













 

ȣ : () κ ڵϹȣ:214-86-56219 ǸžŰ19-2544 ǥ: Ŵ뼷 ȭ:(02)2679-8556 Fax :(02)2679-8557
: ⵵ õ ̱ 뵿 õ ũũ 401 502ȣ     繫 : 4 8-1 4
Copyright(C) 2004, () κ ý All Rights Reserved E-Mail : WebMaster