User Tools

Site Tools


en:playground:words:dup

dup simply duplicates the top of the stack. It's a code word.

To see how F-PC v3.6 defines DUP, perform below steps.

1. Launch F-PC v3.6 (A famous DOS Forth)

2. Type in: “see dup”. FPC replies:

DUP is Code, load DISASSEM to see it. ok

3. So I type in: “load disassem”.

A file MUST be open to perform this operation.

4. So I type: “open disassem”.

open disassem of 16329 bytes. ok

5. Let's continue: “load disassem”.

Loading..ESC_TO_EXIT
6F6C 61
Stack Empty.    OOPS!  <--- oops! sounds like there's a problem but it can be ignored.

6. Let's see how DUP is defined. Type: “see dup”

 ESC_TO_EXIT
 568 8B  SP DI MOV,                8B FC              .|  <---- DUP 's definition start from here
 56A FF  0 [DI] PUSH,              FF 35              .5
 56C 26  ES:                       26                 &   <---- >NEXT
 56D AD  WORD LODS,                AD                 -   
 56E FF  AX #) JMP,                FF E0              .`  <---- end of DUP's definition
 570 5A  DX POP,                   5A                 Z   <---- start of the next word's definition
 571 58  AX POP,                   58                 X
 
en/playground/words/dup.txt · Last modified: 2013-06-06 21:26 by 127.0.0.1