News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Example Z80 assembly programs (was:ASM source code)

Started by arnoldemu, 08:59, 04 April 10

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

AMSDOS

Hi @Urusergi

Unfortunately I'm unable to remember what that BASIC program was, had a feeling it might of been a program which had BASIC code as well as a binary file, but I don't know that for sure. Back in 2015 I was typing in a few large programs from various magazines like Your Computer. I checked out programs which I might have considered for it, but they weren't 12kb. The only thing I could think of which came close is the early AMSOFT game Quack-A-Jack, which has a 12kb binary file & 14kb BASIC file.

It maybe better though to use one of my BASIC programs, rather than invite trouble. At the moment I've been working on this program, and made some progress with it yesterday after adding enemy tank (with the help I had from an AA Type-in), I also improved the shooting sequence, so the tanks can move after shots have been fired. I probably might just add some colourful sprites to the program before handing it to you if you wanted to test that.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Urusergi

Quote from: AMSDOS on 10:27, 31 January 15
4) I though this method could be used to load a BASIC program using Headerless loader and then execute this using this method, but only really makes sense to apply it for a larger program. Any thoughts
Do you know "2cdt" x86 program?. I think that is what you need. You can create 2 unique blocks whatever the size of the basic game. The first block can be as small as 1 byte, and the second with the rest of bytes (and you can adjust the speed too). Obviously the biggest problem is when you get a "read error b" and you have to start charging again from the beginning  :doh:

Quote from: AMSDOS on 23:23, 24 March 18
I probably might just add some colourful sprites to the program before handing it to you if you wanted to test that.
Ok, pass it to me when you finish ;)

AMSDOS

Quote from: Urusergi on 00:41, 25 March 18
Do you know "2cdt" x86 program?. I think that is what you need. You can create 2 unique blocks whatever the size of the basic game. The first block can be as small as 1 byte, and the second with the rest of bytes (and you can adjust the speed too). Obviously the biggest problem is when you get a "read error b" and you have to start charging again from the beginning  :doh: 


It's not a problem producing a Headerless file with 2cdt, but I thought the problem is loading a headerless file over another BASIC program which is trying to load it, hence write Assembly program to load file from another location, then use Assembly routine to run the BASIC program.


Quote
Ok, pass it to me when you finish ;)


Are you sure? Winking emoji usually means do the opposite.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Urusergi

#153
Quote from: AMSDOS on 11:12, 25 March 18It's not a problem producing a Headerless file with 2cdt, but I thought the problem is loading a headerless file over another BASIC program which is trying to load it, hence write Assembly program to load file from another location, then use Assembly routine to run the BASIC program.
No, I mean create 2 turbo blocks with header that are still firmware compatible. It's almost as fast as a headerless file and can be executed with run ""

Quote from: AMSDOS on 11:12, 25 March 18Are you sure? Winking emoji usually means do the opposite.
??? At least in my country I think it means that I am willing to help or I agree to help you. Let's see if other Spaniards corroborate me or I'm wrong.
In this forum I've always helped in everything I could, maybe that's the reason I 've more likes than posts.

adolfo.pa

Quote from: Urusergi on 16:39, 25 March 18
??? At least in my country I think it means that I am willing to help or I agree to help you. Let's see if other Spaniards corroborate me or I'm wrong.

Sorry @Urusergi , I think you're wrong about the emoji  :) Northern spaniard here, and I've always used it as a "just joking" indicator.

Urusergi

Quote from: adolfo.pa on 20:21, 25 March 18
Sorry @Urusergi , I think you're wrong about the emoji  :) Northern spaniard here, and I've always used it as a "just joking" indicator.

Then I'm going to have to erase a few thousand of smiles that I put in ~15 years that I've been writing in forums and, interestingly, nobody told me anything about my mistake (in fact, they always reacted positively).

For example, someone sends me this message recently:
"Is it possible to have a version without the crosshair fix, we will have the option of on or off then.  ;) "

What should I understand? Is it a joke? and he doesn't really want me to do that version?

adolfo.pa

Quote from: Urusergi on 21:19, 25 March 18
Then I'm going to have to erase a few thousand of smiles that I put in ~15 years that I've been writing in forums and, interestingly, nobody told me anything about my mistake (in fact, they always reacted positively).

For example, someone sends me this message recently:
"Is it possible to have a version without the crosshair fix, we will have the option of on or off then.  ;) "

What should I understand? Is it a joke? and he doesn't really want me to do that version?

It is definitely a friendly emoji, so it is natural for people to react to it in a positive way. Also, most of the time the meaning will be obvious given the context; in your response it is pretty clear you used it with the meaning of a regular smiley (friendlyness).

I use it to make sure people know I'm joking. For example, the other day I posted this as a response to Duke:
QuotePlease stop making so many cool stuff! You make the rest of us look like lazy couch potatos (which we aren't, of course  ;) )

If you remove the wink smiley the meaning changes quite a lot  :)

Not exactly an authoritative source of information, but here is the entry in the Emojipedia.

Urusergi

@adolfo.pa I think you're not understanding the approach.

AMSDOS thinks I'm not going to help him with the problem if I tell him in this way:
"Ok, pass it to me when you finish  ;) "

Recently someone (foreign) asked me for help in this way:
"Is it possible to have a version without the crosshair fix, we will have the option of on or off then.  ;) "

Of course I made that version he asked me and I didn't think he was kidding

That's why I think that depending on the country we may understand the emoticons in different ways.

What do you think in this case?

Urusergi

@AMSDOS as you haven't finished your game yet, I've created two examples with a spanish game (Star Sordium):

- Original is 10 Blocks at 2000 baud and loads in 2 minutes and 11 seconds.

- 2 Blocks at 2000 baud loads in 1 minute and 23 seconds.

- 2 Blocks at 2500 baud loads in 1 minute and 6 seconds.


look at the attachments (here I used to put a wink emoticon, but better not)

adolfo.pa

Quote from: Urusergi on 23:03, 25 March 18
What do you think in this case?

Well, I think you're giving too much importance to this  ;)

I don't think there's any country specific thing going on here, and AFAIK, the meaning of the winky smiley is the same on all western/european countries. In my job I chat regularly with people from western europe, USA, and Brazil, and all of them seem to use it in that sense. Proof of that is that I haven't been fired yet :D

Cheers!

Urusergi

Quote from: adolfo.pa on 23:33, 25 March 18
Well, I think you're giving too much importance to this  ;)
I don't give importance, it's just curiosity but I see that you don't want to answer (Lo entiendo  ;) )

Let's leave it that way....

adolfo.pa

Quote from: Urusergi on 23:47, 25 March 18
I don't give importance, it's just curiosity but I see that you don't want to answer (Lo entiendo  ;) )

Now I'm confused, because I though I had answered you  ???

Anyway, this is waaay off-topic, so yep, let's forget about it.

Cheers!

AMSDOS

Quote from: Urusergi on 16:39, 25 March 18
No, I mean create 2 turbo blocks with header that are still firmware compatible. It's almost as fast as a headerless file and can be executed with run ""


I'm familiar with that approach as I used to do that with all my AMSOFT games with JL-Copy, but that's not taking my BASIC program and using and Assembly routine to execute that BASIC from Assembly. I think the size of my BASIC code and number of variables it uses throws me in the deep end when it comes to that routine, I think it just needs a short program with a couple of variables just to show it's function properly, but as it is I'm having trouble following it.


* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Urusergi

Ok, I see that you want to use exclusively the machine code routine for load, and then run the basic file.

Tonight I'll try with a little example.


AMSDOS

It doesn't have to load, but I would like to see it in an Assembler format with the BASIC embedded in as defb statements. I think something simple like this should be fine:


10 a%=1000
20 b%=256
30 PRINT a%+b%
40 PRINT"8)"
50 END



Thanks
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Urusergi

Sorry but I've already created a headerless file with my prime number generator in basic.

Machine code:

kl_rom_select equ &B90F

org &A000

ld hl,&0170  ; load basic start
ld de,&00E9 ; basic length
ld a,&16  ; sync file char
call &bca1

ld hl,(length)
ld c,0
call kl_rom_select
ld a,(&c002)
cp 0
jp z,cpc464
ld (&ae66),hl
ld (&ae68),hl
ld (&ae6a),hl
ld (&ae6c),hl
cp 1
jp z,cpc664
jp &ea78        ;; run BASIC CPC6128
.cpc664
jp &ea7d        ;; run BASIC CPC664
.cpc464
ld (&ae83),hl
ld (&ae85),hl
ld (&ae87),hl
ld (&ae89),hl
jp &e9bd        ;; run BASIC CPC464


length dw &025A ; Address of start of variables (&AE66-67 in cpc6128-664, &AE83-84 in cpc464)


If you don't understand something, don't hesitate to ask me, but I think it's pretty simple to follow.



Urusergi

@AMSDOS Here is your Basic example  8)

kl_rom_select equ &B90F

ORG &A000

LD HL,Data
LD DE,&0170  ; Basic start
LD BC,EndData-Data
LDIR

ld hl,(length)
ld c,0
call kl_rom_select
ld a,(&c002)
cp 0
jp z,cpc464
ld (&ae66),hl
ld (&ae68),hl
ld (&ae6a),hl
ld (&ae6c),hl
cp 1
jp z,cpc664
jp &ea78        ;; run BASIC CPC6128
.cpc664
jp &ea7d        ;; run BASIC CPC664
.cpc464
ld (&ae83),hl
ld (&ae85),hl
ld (&ae87),hl
ld (&ae89),hl
jp &e9bd        ;; run BASIC CPC464


;PRINT HEX$(PEEK(&AE67))
;PRINT HEX$(PEEK(&AE66))
length dw &01AC ; Address of start of variables (&AE66-67 in cpc6128-664, &AE83-84 in cpc464)

.Data
DB &0D,&00,&0A,&00,&02,&00,&00,&E1
DB &EF,&1A,&E8,&03,&00,&0D,&00,&14
DB &00,&02,&00,&00,&E2,&EF,&1A,&00
DB &01,&00,&10,&00,&1E,&00,&BF,&20
DB &02,&00,&00,&E1,&F4,&02,&00,&00
DB &E2,&00,&0A,&00,&28,&00,&BF,&22
DB &38,&29,&22,&00,&06,&00,&32,&00
DB &98,&00,&00,&00
.EndData

ikonsgr


AMSDOS

Quote from: ikonsgr on 09:39, 01 July 18
You might want to add this code to Source codes too.


I've added a page, please inspect it though. Registration to the CPCWiki is seperate from the forum, so feel free to register and amend where necessary.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

ikonsgr


issalig

Hi  @Urusergi , I have a question about the code, why 170+code_size is copied 4 times?

Quote from: Urusergi on 21:10, 27 March 18@AMSDOS Here is your Basic example  8)

kl_rom_select equ &B90F

ORG &A000

LD HL,Data
LD DE,&0170  ; Basic start
LD BC,EndData-Data
LDIR

ld hl,(length)
ld c,0
call kl_rom_select
ld a,(&c002)
cp 0
jp z,cpc464
ld (&ae66),hl
ld (&ae68),hl
ld (&ae6a),hl
ld (&ae6c),hl
cp 1
jp z,cpc664
jp &ea78        ;; run BASIC CPC6128
.cpc664
jp &ea7d        ;; run BASIC CPC664
.cpc464
ld (&ae83),hl
ld (&ae85),hl
ld (&ae87),hl
ld (&ae89),hl
jp &e9bd        ;; run BASIC CPC464


;PRINT HEX$(PEEK(&AE67))
;PRINT HEX$(PEEK(&AE66))
length dw &01AC ; Address of start of variables (&AE66-67 in cpc6128-664, &AE83-84 in cpc464)

.Data
DB &0D,&00,&0A,&00,&02,&00,&00,&E1
DB &EF,&1A,&E8,&03,&00,&0D,&00,&14
DB &00,&02,&00,&00,&E2,&EF,&1A,&00
DB &01,&00,&10,&00,&1E,&00,&BF,&20
DB &02,&00,&00,&E1,&F4,&02,&00,&00
DB &E2,&00,&0A,&00,&28,&00,&BF,&22
DB &38,&29,&22,&00,&06,&00,&32,&00
DB &98,&00,&00,&00
.EndData


Urusergi

Quote from: issalig on 15:58, 08 June 21
Hi  @Urusergi , I have a question about the code, why 170+code_size is copied 4 times?


Hi, those four memory locations must have the same data. You can find out what they mean in this web page:

http://www.cantrell.org.uk/david/tech/cpc/cpc-firmware/mem-use.htm


Look at &AE66, &AE68, &AE6A, &AE6C




NicolasCanadea

Hello, i'm learning about assembler z80. First i created a asm code with CPCTelera. When i read the default code i see for example the lines :

.area _DATA
----
---
.area _CODE

what mean these? for example i imagine _DATA is a macro define. DATA and CODE are areas of data programme (256bytes) and CODE is code programme. But the compiler start with $4000 address, how set this address? 

asertus

#173
Quote from: NicolasCanadea on 11:51, 28 August 22Hello, i'm learning about assembler z80. First i created a asm code with CPCTelera. When i read the default code i see for example the lines :

.area _DATA
----
---
.area _CODE

what mean these? for example i imagine _DATA is a macro define. DATA and CODE are areas of data programme (256bytes) and CODE is code programme. But the compiler start with $4000 address, how set this address?

Actually those areas are required due to the assembler version that it uses.

You may write everything after your .area _CODE line.

In cpctelera, there is a configuration file for make,

./cfg/build_config.mk and there you can find that configuration,

# Name of the project (without spaces, as it will be used as filename)
#   and Z80 memory location where code will start in the generated binary
PROJNAME   := menace
Z80CODELOC := 0x4000

there you have default code location. You may update it if required.








reidrac

I would give a go to a different assembler.

CPCTelera uses the SDCC compiler suite that comes with an assembler that is powerful but has a few weird things in its syntax. On top of that, it uses a linker, and that's where the code and data sections kick in.

Is not impossible, but if you aren't using C, it adds a lot of complexity that may not play in your favour if you're learning.

Some people use pasmo, rasm, or the winape integrated assembler. IMHO those are better options.
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse, Brick Rick and Hyperdrive for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Powered by SMFPacks Menu Editor Mod