Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Zilog Z8000
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Example code === The following Z8000 assembly source code is for a subroutine named <code>MEMCPY</code> that copies a block of data words from one location to another. The data block is copied one word at a time, and the data movement and looping logic utilizes 16-bit operations. It demonstrates a variety of instructions but in practice it would not be coded this way as the Z8000 has a single instruction that will replace this entire subroutine: <code>LDIR</code>. The sample code will move one word every 34 cycles. Substituting the <code>LDIR</code> instruction will move a word in only 9 cycles. <!--This was assembled by brain so it may contain errors. I realize two instructions and some cycles could be saved by using POP @R2,@R1 to move the data but that would obfuscate the example.--> {| |-valign="top" |<syntaxhighlight lang="text"> 1000 1000 93F4 1002 1002 2114 1004 2F24 1006 A911 1008 A921 100A F285 100C 100C 97F4 100E 9E08 1010 </syntaxhighlight> |<syntaxhighlight lang="tasm"> ; memcpy -- ; Copy a block of memory from one location to another. ; This routine is the equivalent of ; LDIR @R2,@R1,R0 (LDIR @dst,@src,cnt) ; ; Entry registers ; R1 - Address of source data block ; R2 - Address of destination data block ; R0 - Number of words to copy ; ; Return registers ; R1 - First word after source data block ; R2 - First word after destination data block ; R0 - Zero ORG 1000h ;Origin at 1000h MEMCPY: PUSH @R15,R4 ;Save temp register like LDIR LOOP: LD R4,@R1 ;Load source word LD @R2,R4 ;save it INC R1,#2 ;Bump source by 2 for words INC R2,#2 ;Bump dest pointer by 2 DJNZ R0,LOOP ;Bump count, loop if != 0 POP R4,@R15 ;Restore temp register RET END </syntaxhighlight> |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)