[ASM] Enter an hexadecimal machine code listing.

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

[ASM] Enter an hexadecimal machine code listing.

Post by XavSnap »

Hi,

There's two ways to enter an hexadecimal listing:

In Basic:

Code: Select all

1 REM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2 LET A$="2A294001050009545D0100023E0\
07E23D61CF8A9052807070707074F18F0EB77\
EB1318E5"
3 LET B=16514
4 FOR A=1 TO LEN A$-1 STEP 2
5 POKE B,16*CODE A$(A)+CODE A$(A+1)-476
6 LET B=B+1
7 NEXT A
And in Machine code:
Put the RAND USR before the REM line in hexadecimal (a space or a code <"0" stop the process).
The code will be fill in this REM
Delete the first REM and the RAND one...

Code: Select all

;------- TASM ASM mnemonics. -------
; Compile this file using:
; Set TASMOPTS = -b
; tasm -80 ThisCode.tas MyBinary.BIN
;-----------------------------------


#define ORG  .org       ; TASM cross-assembler definitions
#define equ  .equ


;------- Rom and Ram Symbols -------
RAM_D_FILE equ $400C
RAM_NEXT_LINE equ $4029

ORG $4082 ; [@16514/@h4082]
	LD HL,(RAM_NEXT_LINE)
	LD BC,$5
	ADD HL,BC
	LD D,H
	LD E,L
RESCAN:
	LD BC,$200
	LD A,0
LOOP:
	LD A,(HL)
	INC HL
	SUB $1C
	RET M
	XOR C
	DEC B
	JR Z,NEXT
	RLCA
	RLCA
	RLCA
	RLCA
	LD C,A

	JR LOOP
NEXT:
	EX DE,HL
	LD (HL),A
	EX DE,HL
	INC DE
	JR RESCAN
.end

Code: Select all

     0  REM [HEX:\
2A,29,40,01,05,00,09,54,\
5D,01,00,02,3E,00,7E,23,\
D6,1C,F8,A9,05,28,07,07,\
07,07,07,4F,18,F0,EB,77,\
EB,13,18,E5 ]

     1 RAND USR 16514

     2  REM [HEX:\
1D,1D,1E,1E,26,26,20,21,\
22,23,24,25,2B,2B,0D,00,\
 ]

or

("$" char stop the process)

Code: Select all

;------- TASM ASM mnemonics. -------
; Compile this file using:
; Set TASMOPTS = -b
; tasm -80 ThisCode.tas MyBinary.BIN
;-----------------------------------


#define ORG  .org       ; TASM cross-assembler definitions
#define equ  .equ

;------- Rom and Ram Symbols -------
RAM_D_FILE equ $400C
RAM_NEXT_LINE equ $4029

ORG $4082 ; [@16514/@h4082]
	LD HL,(RAM_NEXT_LINE)
	LD BC,$5
	ADD HL,BC
	LD D,H
	LD E,L
LOOP:
	LD A,(HL)
	CP $0D ; "$"
	RET Z
	SUB $1C
	RLCA
	RLCA
	RLCA
	RLCA
	INC HL
	ADD A,(HL)
	INC HL
	SUB $1C
	EX DE,HL
	LD (HL),A
	EX DE,HL
	INC DE
	JR LOOP

.end

Code: Select all

     0  REM [HEX:\
2A,29,40,01,05,00,09,54,\
5D,7E,FE,0D,C8,D6,1C,07,\
07,07,07,23,86,23,D6,1C,\
EB,77,EB,13,18,EB ]

     1 RAND USR 16514

     2  REM [HEX:\
1D,1D,1E,1E,26,26,20,21,\
22,23,24,25,2B,2B,0D,00,\
 ]
Attachments
BASIC.P
(1.13 KiB) Downloaded 145 times
ASM1.P
(987 Bytes) Downloaded 140 times
ASM0.P
(993 Bytes) Downloaded 135 times
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Post Reply