Machine Code Problem

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
mrtinb
Posts: 1911
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Machine Code Problem

Post by mrtinb »

The numbers 0 - 9 on the ZX81 is character number 28 to 37. Thus if you have a number between 0 and 9, and add 28, you get the characters '0' to '9'.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
MrVertigo
Posts: 106
Joined: Fri May 27, 2022 9:06 pm

Re: Machine Code Problem

Post by MrVertigo »

But to get the number to display as a decimal rather than a ZX81 character graphic, is it the ADD A, 28 line that is accomplishing that?
MrVertigo
Posts: 106
Joined: Fri May 27, 2022 9:06 pm

Re: Machine Code Problem

Post by MrVertigo »

Oops we’re out of step. :D Thanks for the detailed explanation. That’s great!
dr beep
Posts: 2080
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Machine Code Problem

Post by dr beep »

dr beep wrote: Wed Jul 05, 2023 11:45 am First routine until the space-line

A holds number, HL holds position on screen

19A38E58-B8D2-4B12-85FF-9F993FC524B2.png
This is the shortened version I used in a later game

Code: Select all

	ld	hl,location-1
	ld	bc,#364				; 3 loops, 100 10 and units, 100 first
set0	inc	hl				; goto current position
	ld	(hl),27				; signal "-1"
setp	inc	(hl)				; add 1 to position
	sub	c				; take of 100 or 10
	jr	nc,setp				; continu sub
	add	a,c				; undo last change
	ld	c,10				; 10 is next position
	djnz	set0				; do 10 and 1, but 1 as 10
	add	a,(hl)				; 1 is shown as "0"
	ld	(hl),a				;  now show units
User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Machine Code Problem

Post by 1024MAK »

MrVertigo wrote: Wed Jul 05, 2023 2:15 pm But to get the number to display as a decimal rather than a ZX81 character graphic, is it the ADD A, 28 line that is accomplishing that?
That’s what I was trying to demonstrate with the BASIC program in my earlier post

But simply adding 28 only works if your number is a single digit. You have to deal with each digit individually.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
MrVertigo
Posts: 106
Joined: Fri May 27, 2022 9:06 pm

Re: Machine Code Problem

Post by MrVertigo »

1024MAK wrote: Wed Jul 05, 2023 7:38 pm
MrVertigo wrote: Wed Jul 05, 2023 2:15 pm But to get the number to display as a decimal rather than a ZX81 character graphic, is it the ADD A, 28 line that is accomplishing that?
That’s what I was trying to demonstrate with the BASIC program in my earlier post

But simply adding 28 only works if your number is a single digit. You have to deal with each digit individually.

Mark
Ah, I see what your basic program is doing now!
MrVertigo
Posts: 106
Joined: Fri May 27, 2022 9:06 pm

Re: Machine Code Problem

Post by MrVertigo »

dr beep wrote: Wed Jul 05, 2023 4:34 pm
dr beep wrote: Wed Jul 05, 2023 11:45 am First routine until the space-line

A holds number, HL holds position on screen

19A38E58-B8D2-4B12-85FF-9F993FC524B2.png
This is the shortened version I used in a later game

Code: Select all

	ld	hl,location-1
	ld	bc,#364				; 3 loops, 100 10 and units, 100 first
set0	inc	hl				; goto current position
	ld	(hl),27				; signal "-1"
setp	inc	(hl)				; add 1 to position
	sub	c				; take of 100 or 10
	jr	nc,setp				; continu sub
	add	a,c				; undo last change
	ld	c,10				; 10 is next position
	djnz	set0				; do 10 and 1, but 1 as 10
	add	a,(hl)				; 1 is shown as "0"
	ld	(hl),a				;  now show units
Nice!
MrVertigo
Posts: 106
Joined: Fri May 27, 2022 9:06 pm

Re: Machine Code Problem

Post by MrVertigo »

When you get down to this level of programming it makes it even more hilarious to hear some people say computers can become sentient. :D
User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Machine Code Problem

Post by 1024MAK »

MrVertigo wrote: Wed Jul 05, 2023 10:26 pm When you get down to this level of programming it makes it even more hilarious to hear some people say computers can become sentient. :D
HAL 9000 disagrees :lol:

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
MrVertigo
Posts: 106
Joined: Fri May 27, 2022 9:06 pm

Re: Machine Code Problem

Post by MrVertigo »

:D
Post Reply