Machine code: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 1,866: | Line 1,866: | ||
{{out}} |
{{out}} |
||
<pre>19</pre> |
<pre>19</pre> |
||
⚫ | |||
<lang z80>;;;;;;;;;;;;;;;;;;; HEADER ;;;;;;;;;;;;;;;;;;; |
|||
read "\SrcCPC\winape_macros.asm" |
|||
read "\SrcCPC\MemoryMap.asm" |
|||
read "\SrcALL\winapeBuildCompat.asm" |
|||
read "\SrcALL\lib\z80_opcode_chart.asm" |
|||
;;;;;;;;;;;;;;;;;;; PROGRAM ;;;;;;;;;;;;;;;;;;; |
|||
org &1000 |
|||
ld hl,machine_code_area |
|||
;assembles the following: |
|||
;LD A,7 |
|||
;ADD 12 |
|||
;DAA |
|||
;CALL SHOWHEX |
|||
;RET |
|||
ld (hl),&3E ;LD A,nn |
|||
inc hl |
|||
ld (hl),7 |
|||
inc hl |
|||
ld (hl),&C6 ;ADD nn |
|||
inc hl |
|||
ld (hl),12 |
|||
inc hl |
|||
ld (hl),&27 ;DAA |
|||
inc hl |
|||
ld (hl),&CD ;call |
|||
inc hl |
|||
ld (hl),&00 ;low byte of address of showhex |
|||
inc hl |
|||
ld (hl),&11 ;high byte of address of showhex |
|||
inc hl |
|||
ld (hl),&C9 ;RET |
|||
;FALLTHROUGH IS INTENTIONAL |
|||
machine_code_area: |
|||
;0 = nop |
|||
byte 0,0,0,0,0,0,0,0 |
|||
byte 0,0,0,0,0,0,0,0 |
|||
byte 0,0,0,0,0,0,0,0 |
|||
byte 0,0,0,0,0,0,0,0 |
|||
byte 0,0,0,0,0,0,0,0 |
|||
byte 0,0,0,0,0,0,0,0 |
|||
byte 0,0,0,0,0,0,0,0 |
|||
byte 0,0,0,0,0,0,0,0 |
|||
org &1100 |
|||
read "\SrcCPC\winape_showhex.asm" ;showhex is at &1100 thanks to the org. |
|||
read "\SrcCPC\winape_stringop.asm"</lang> |
|||
If you were doing this for real, it's much better to define the opcodes as labels so that you don't need to memorize them. (I really wish assemblers let you use instruction names as aliases for data, but I imagine that would make parsing much more difficult. Oh well.) |
|||
{{omit from|360 Assembly}} |
{{omit from|360 Assembly}} |
||
{{omit from|6502 Assembly|Assembly is just machine code in a human-readable form, so you're already there}} |
|||
{{omit from|68000 Assembly}} |
|||
{{omit from|8080 Assembly}} |
{{omit from|8080 Assembly}} |
||
{{omit from|8086 Assembly}} |
{{omit from|8086 Assembly}} |
||
Line 1,877: | Line 1,928: | ||
{{omit from|MIPS Assembly}} |
{{omit from|MIPS Assembly}} |
||
{{omit from|x86 Assembly}} |
{{omit from|x86 Assembly}} |
||
⚫ |