Simple test machine can now load an arbitrary program binary
parent
6efdfecf54
commit
05fcb7b7f7
@ -1,2 +1,3 @@
|
||||
/target
|
||||
*.pdf
|
||||
*.bin
|
||||
@ -0,0 +1,37 @@
|
||||
# Load string into memory at the output address
|
||||
0xA2, b'H', # LDX H
|
||||
0x86, output_addr, # STX
|
||||
0xA2, b'e', # LDX e
|
||||
0x86, output_addr + 1, # STX
|
||||
0xA2, b'l', # LDX l
|
||||
0x86, output_addr + 2, # STX
|
||||
0xA2, b'l', # LDX l
|
||||
0x86, output_addr + 3, # STX
|
||||
0xA2, b'o', # LDX o
|
||||
0x86, output_addr + 4, # STX
|
||||
|
||||
0xA2, b' ', # LDX ' '
|
||||
0x86, output_addr + 5, # STX
|
||||
|
||||
0xA2, b'w', # LDX w
|
||||
0x86, output_addr + 6, # STX
|
||||
0xA2, b'o', # LDX o
|
||||
0x86, output_addr + 7, # STX
|
||||
0xA2, b'r', # LDX r
|
||||
0x86, output_addr + 8, # STX
|
||||
0xA2, b'l', # LDX l
|
||||
0x86, output_addr + 9, # STX
|
||||
0xA2, b'd', # LDX d
|
||||
0x86, output_addr + 10, # STX
|
||||
0xA2, b'!', # LDX !
|
||||
0x86, output_addr + 11, # STX
|
||||
|
||||
0xA2, 0x00, # LDX 0
|
||||
0x86, output_addr + 12, # STX
|
||||
|
||||
# Set flag to do the print
|
||||
0xA2, 0x01, # LDX 1
|
||||
0x86, print_flag_addr, # STX
|
||||
|
||||
# End the program
|
||||
0x60 # RTS
|
||||
@ -0,0 +1,26 @@
|
||||
|
||||
; Multiply 7 with 10 and print the result
|
||||
|
||||
; FAST MULTIPLY program from:
|
||||
; http://6502.org/source/integers/fastx10.htm
|
||||
main LDA #7 ; load 7 into the accumulator
|
||||
ASL ;multiply by 2
|
||||
STA TEMP ;temp store in TEMP
|
||||
ASL ;again multiply by 2 (*4)
|
||||
ASL ;again multiply by 2 (*8)
|
||||
CLC
|
||||
ADC TEMP ;as result, A = x*8 + x*2
|
||||
|
||||
; PRINT RESULT
|
||||
STA $A0 ; 0x85, 0xA0, ; store A into the output addr
|
||||
LDX #0 ; 0xA2, 0x00, ; null terminator
|
||||
STX $A1 ; 0x86, 0xA1, ; store null terminator to output addr + 1
|
||||
|
||||
; Set flag to do the print
|
||||
LDX #1 ; 0xA2, 0x01,
|
||||
STX $9F ; 0x86, 0x9F,
|
||||
|
||||
; End the program
|
||||
RTS ; 0x60
|
||||
|
||||
TEMP .byte 0
|
||||
Loading…
Reference in New Issue