Print itself: Difference between revisions
m
→{{header|Z80 Assembly}}: displayed bytecode alongside assembly
Puppydrum64 (talk | contribs) m (added output and fixed formatting) |
Puppydrum64 (talk | contribs) m (→{{header|Z80 Assembly}}: displayed bytecode alongside assembly) |
||
Line 176:
=={{header|Z80 Assembly}}==
This program prints its bytecode as text to the Amstrad CPC terminal. The program is run by typing <code>call &1000</code> to the screen.
<pre>WinAPE Z80 Assembler V1.0.13
000003 1001 21 01 10 ld hl,&1001
000004 1004 1E FF ld e,&ff
000005 1006 1C inc e
000006 1007 loop
000007 1007 7E ld a,(hl)
000008 1008 BB cp e
000009 1009 CA 2B 10 jp z,ProgramEnd
000011 100C CD 36 10 call UnpackNibbles
000012 100F 78 ld a,b
000013 1010 FE 0A cp &0A
000014 1012 38 02 jr c,noCorrectHex_B
000015 1014 C6 07 add &07
000016 1016 noCorrectHex_B
000017 1016 C6 30 add &30
000018 1018 CD 5A BB call &bb5a
000020 101B 79 ld a,c
000021 101C FE 0A cp &0A
000022 101E 38 02 jr c,noCorrectHex_C▼
000023 1020 C6 07 add &07
▲jr c,noCorrectHex_C
000024 1022 noCorrectHex_C
000025 1022 C6 30 add &30
000026 1024 CD 5A BB call &bb5a
000027 1027 23 inc hl
000028 1028 C3 07 10 jp loop
000029 102B ProgramEnd
000030 102B 3E 30 ld a,&30
000031 102D CD 5A BB call &bb5a
000032 1030 3E 30 ld a,&30
000033 1032 CD 5A BB call &bb5a
000034 1035 C9 ret ;return to basic▼
000037 1036 UnpackNibbles
▲ret ;return to basic
000038 1036 ;splits a into its component nibbles, storing high nibble in B and low in C.▼
000039 1036 F5 push af
000040 1037 E6 0F and &0f
000041 1039 4F ld c,a
▲;splits a into its component nibbles, storing high nibble in B and low in C.
000042 103A F1 pop af
000043 103B E6 F0 and &f0
000044 103D 0F rrca
000045 103E 0F rrca
000046 103F 0F rrca
000047 1040 0F rrca
000048 1041 47 ld b,a
000049 1042 C9 ret
000051 1043 00 db 0 ;this must be the only instance of 00 in the bytecode for this to work.
</pre>
{{out}}
[https://ibb.co/KbzjpNQ Output on WinAPE]
|