Getting started with MSX coding (assembler)

Page 2/4
1 | | 3 | 4

By jltursan

Prophet (2619)

jltursan's picture

26-09-2008, 19:21

However, the current version has some bugs which were to be worked out in version 0.13, but no news so far

Hey!, Pitpan has ironed out a lot the assembler and the new version (alpha) is out. You can download it from this Karoshi's Forum thread. Look for version 0.15a in the last pages of the thread :)

@Sdw: Although I'm using mostly sjASM; as part of a starter kit, I really think that asMSX has the most useful features for a MSX programmer: specific MSX pseudoinstructions, full program examples, good manual, etc. When you feel more used to the platform you can switch to other assemblers more advanced.

Also, in the above forum, you can find a lot of code snippets, most of them ready to go after some copy-paste and compiling under asMSX. Take a look here

By Metalion

Paragon (1622)

Metalion's picture

26-09-2008, 19:40

Hey!, Pitpan has ironed out a lot the assembler and the new version (alpha) is out. You can download it from this Karoshi's Forum thread. Look for version 0.15a in the last pages of the thread :)
Hey !!! Great News !!! LOL!LOL!LOL!
Pitpan, you should make an official news topic out of it ...

By nikodr

Paladin (750)

nikodr's picture

26-09-2008, 20:17

It's good although i only found the exe file,is there some documentation about the usage?I was using tni asm should i change it to this one?It seems good.However most asm require different syntax methods and i want to stick to only one.So is there any other docs or files for that assembler?

By nikodr

Paladin (750)

nikodr's picture

26-09-2008, 20:27

What do i need to do to make bin files? in the other assemblers i used something like

db 0x0FE
dw start, endadr, start
org 0xaddress
start: <do some asm here>
.
.
.
endadr: end

(i use this in tni.asm)
is there a way that i can include this as an external source file that would help me create msx binaries or rom files if i need?
I dont want to type in the start of my program every time.
Thank you!

By Metalion

Paragon (1622)

Metalion's picture

26-09-2008, 20:59

nikodr,

The manual of AsMSX is only availaible in spanish, although I started to translate it in french a while ago, but never had the time to finish it. However, I found the spanish manual quite easy to understand. You will find it along in the 0.12g zip file as I trust that nothing much changed between 0.12g and 0.15a, as the later versions mainly dealt with core bugs.

To generate a .bin file in asMSX, just put the following at the top of your code :

. BASIC
. ORG 0xaddress
. START startaddress

By Yukio

Paragon (1540)

Yukio's picture

27-09-2008, 02:06

1) Download PASMO to assemble on a PC
2) Download Notepad++ to create files
3) Use this "template"

--- CUT HERE ---
INITTXT EQU #006c
INIT32 EQU #006f
INITGRP EQU #0072
INIMLT EQU #0075

CHPUT EQU #00A2

org #4000
db "AB"
dw start
db 00,00,00,00,00,00

start:

call INITTXT
LD HL,texto
loop:
LD A,(HL)
call CHPUT
inc HL
ld a,0
cp (HL)
JR NZ, loop
fim:
jp fim

texto:
DB 'Hello World of MSX! Im SDW and I just got my NMS 8245 ',00

END

--- CUT HERE ---

RAM is *probably* after $c000
Save that as mycode.asm
Go to DOS and use
pasmo mycode.asm myfirst.rom

use the .ROM on BlueMSX or OpenMSX...

That's it. Direct and easy!

Was not ...

"org #4000
db "AB"
dw start
db 00,00,00,00,00,00,00,00,00,00,00,00"

Programs could start at 4010!The 'important' part is AB, later the start address for example :
41,42,10,40,00,00,00,00
00,00,00,00,00,00,00,00
program start here (4010) ...

By Yukio

Paragon (1540)

Yukio's picture

27-09-2008, 04:02

If you are interested into programming for MSX home computers. It would be possible to pay $$$ to me and get a license to get some samples on disks ...

Or just seek for Books. After all, the difficulty could improve the intellectual levels of individuals !!!

By Yukio

Paragon (1540)

Yukio's picture

27-09-2008, 04:03

Just check the book THE MSX RED BOOK.
MSX-BIOS routines.

Change mode:

LD A,1 ;screen mode (0,1,2,3)
CALL 005FH; CALL CHGMOD

Write VRAM (This works like the VPOKE):
LD A, dd ; dd is the byte number (ASCII character)
LD HL,dddd ; dddd is the VRAM address
CALL 004DH ;CALL WRTVRM

Read VRAM (This works like the VPEEK):
LD A,dd ; byte
LD HL,dddd ;VRAM address
CALL 004AH ;CALL RDVRM

If you wanted to use OUT's with the bytes to the VDP data port, just set the begin address and output the bytes. It is recommended to use some sort of delays or the BIOS routines for send data to the VDP.

Set Read:
LD HL,dddd ;VRAM address
CALL 0050H ;CALL SETRD

Set Write:
LD HL,dddd ;VRAM address
CALL 0053H ;CALL SETWRT

Use OUT 98H to send the data byte.

Screen 0:
40x24 text mode.
Characters on screen VRAM 0000H-03BFH (960 bytes).

Screen 1:
32x24 text mode.
Characters on screen VRAM 1800H-1AFFH (768 bytes).

Just change the screen to one of the text modes and write the bytes to the correct VRAM address to see the results.

By Sdw

Resident (50)

Sdw's picture

28-09-2008, 19:28

Alright, I have manged to get a little charplasma going now (that's the democoders equivalent of Hello World! Tongue)

I'm still a bit confused on the VDP though. I read somewhere that you could only access VDP during the vertical blank period, otherwise you would get lockups...?
I did some tests with a loop that constantly wrote to VRAM using the VDP, and it seemed to work fine, have I misunderstood something?

Speaking of VBL, I also wanted to find a way to wait for VBL to time my effects. There seems to be a standard interrupt that kicks once per frame, so I did like this

ei
halt
di

(Enable interrupts, wait for it, then disable again)

Is that a sensible way to make a VBL wait?

Then I do have some issues with setting gfx modes. The BIOS way works fine to set Screen 1 (32x24 text mode). However when I set Screen 0, I get 40x24 as expected in emulator, but on my real MSX (NMS8245) instead I get some kind of MSX2 mode with 80 characters wide screen.

I also tried setting modes with the VDP directly, using the code hitchhiker posted, but then I only get garbage on screen no matter what mode I try. Strange...

By PingPong

Prophet (4096)

PingPong's picture

28-09-2008, 20:21

Alright, I have manged to get a little charplasma going now (that's the democoders equivalent of Hello World! Tongue)

I'm still a bit confused on the VDP though. I read somewhere that you could only access VDP during the vertical blank period, otherwise you would get lockups...?
I did some tests with a loop that constantly wrote to VRAM using the VDP, and it seemed to work fine, have I misunderstood something?

when working on a msx2 @3.5Mhz (V9938 VDP) you can output data to vdp at full z80 speed, even outside VBLANK, no problem at all.
when working on a msx1, (TMS VDP), the maximum speed you can achieve depends if you are in vblank or not.
outside vblank, every byte write or read should wait almost 26 z80 T-States (including the instruction that write data to VDP port 98h)
in vblank, no limit or delay.

For waiting for interrupts the tecnique below is OK, however i do not know why you disable ints

ei
halt



Then I do have some issues with setting gfx modes. The BIOS way works fine to set Screen 1 (32x24 text mode). However when I set Screen 0, I get 40x24 as expected in emulator, but on my real MSX (NMS8245) instead I get some kind of MSX2 mode with 80 characters wide screen.

Umh, may be the real machine remember the width of screen so calling the bios to set screen 0, remember the 80 char width. the width is stored on the CMOS RAM. maybe if you do in basic (on the real machine):

Screen 0
Width 40
SET SCREEN : REM SAVE ON CMOS BATTERY THE WIDTH of 40



I also tried setting modes with the VDP directly, using the code hitchhiker posted, but then I only get garbage on screen no matter what mode I try. Strange...

to get a good setup of the screen mode, you need also to intialize the VRAM....

Page 2/4
1 | | 3 | 4