Machine Code Problem
Re: Machine Code Problem
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'.
Re: Machine Code Problem
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?
Re: Machine Code Problem
Oops we’re out of step. Thanks for the detailed explanation. That’s great!
Re: Machine Code Problem
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
- 1024MAK
- Posts: 5189
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: Machine Code Problem
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 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 being good this year.
ZX81 Chip Pin-outs
ZX81 Video Transistor 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 being good this year.
Re: Machine Code Problem
Ah, I see what your basic program is doing now!1024MAK wrote: ↑Wed Jul 05, 2023 7:38 pmThat’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
Re: Machine Code Problem
Nice!dr beep wrote: ↑Wed Jul 05, 2023 4:34 pmThis is the shortened version I used in a later gameCode: 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
Re: Machine Code Problem
When you get down to this level of programming it makes it even more hilarious to hear some people say computers can become sentient.
- 1024MAK
- Posts: 5189
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: Machine Code Problem
HAL 9000 disagrees
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor 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 being good this year.
ZX81 Chip Pin-outs
ZX81 Video Transistor 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 being good this year.