Загрузка страницы

#53 - BASIC Z80 Machine Code Hex Loader (Sinclair ZX Spectrum / Next)

A BASIC loader program to convert Hexadecimal Machine Code bytes into Decimal Values, store them in memory and execute the program.

HEX LOADER PROGRAM:
Note: Angled brackets are not allowed in YouTube descriptions so replace the [LESS THAN] and [GREATER THAN] placeholders in lines 2030 and 2040 with the appropriate symbols.
===============
10 REM [A simple BASIC program to save and execute a machine code program in memory]
20 RESTORE 5000: REM [Refresh DATA]
30 CLS:REM [Clear the display]
40 PRINT "Press a key to load M.C. program"
50 PAUSE 0: REM [Wait for user to press a key]
60 LET memory=40000: REM [Initialize "memory" varible to store address locations for MC]
70 dim b(2):LET b(1)=16: LET b(2)=1: REM [Initialize hex digit multipliers]
80 spectrum chr$64 :REM [64 column mode]
100 READ i$: REM [Read z80 assembly instruction description]
110 PRINT 'i$,: REM [Print z80 assembly instruction]
120 READ bytenum: REM [Read number of MC bytes for instruction]
130 PRINT "Bytes: ";bytenum
140 FOR f=1 to bytenum: REM [Set loop counter for number of bytes]
150 READ b$: REM [Read a MC byte into the variable "b$"]
152 GOSUB 2000: REM [Convert hex value to decimal and put in "byte"]
160 POKE memory,byte : REM [Save MC byte to memory address]
170 PRINT memory,b$;" ("; PEEK (memory);")": REM [Print memory address and MC byte]
180 IF byte=201 THEN GOTO 1000: REM [Check for RETURN instruction (201)]
190 LET memory=memory+1: REM [Incrememt memory address]
200 NEXT f: REM [Go read next MC byte]
210 PRINT '"Press a key for next instruction"
220 PAUSE 0: REM [Wait for user input]
230 GOTO 100: REM [Go read next z80 instruction]
1000 PRINT '"Press any key to execute M.C."
1010 PAUSE 0: REM [Wait for user input]
1020 RANDOMIZE usr 40000: REM [Execute MC program (stored at address 40000)]
1999 STOP : REM [End program once MC has finished executing]
2000 REM [Convert b$ to decimal number and assign to variable "byte"]
2010 LET byte=0: REM [Reset mc "byte" value]
2020 FOR g=1 TO 2
2030 IF CODE b$(g) [LESS THAN] 48 or CODE b$(g) [GREATER THAN] 70 then print ink 2; "Invalid hex value:";b$:stop
2040 IF CODE b$(g) [GREATER THAN] 64 THEN LET byte=byte + (CODE b$(g)-55)*b(g): GOTO 2060
2050 LET byte=byte+(CODE b$(g)-48)*b(g)
2060 NEXT g
2070 RETURN
5000 REM [MACHINE CODE BYTES BELOW]
5100 DATA "LD A,4",2,"3E","04":REM [Load border color (red) into register A]
5200 DATA "OUT (FE),A",2,"D3","FE":REM [Set border to color stored in register A]
9000 DATA "RETURN",1,"C9":REM [Return to BASIC]

====================
Download Spriteworx games at:
https://spriteworx.itch.io

Join my free Spriteworx Facebook Page (public):
https://www.facebook.com/gaming/Spriteworx

Help support more projects by becoming a Patreon subscriber:
https://patreon.com/Spriteworx

Private facebook group with downloadable content for Patreon subscribers:
https://facebook.com/groups/spriteworx

Видео #53 - BASIC Z80 Machine Code Hex Loader (Sinclair ZX Spectrum / Next) канала Spriteworx
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
10 июля 2022 г. 6:00:11
00:28:32
Яндекс.Метрика