Question about Tniasm.How to make bin files:

Page 3/4
1 | 2 | | 4

By Manuel

Ascended (16637)

Manuel's picture

18-03-2008, 18:35

It would be cool to combine such an asssembler IDE with an MSX emulator... I mean, the IDE making use of the emulator to quickly test stuff, e.g. or assemble to RAM.

PS: d-fader, I meant this... http://headlessbarbie.com/blog/?p=13 Maybe you should contact him to ask him what's the problem...

By NYYRIKKI

Enlighted (5540)

NYYRIKKI's picture

18-03-2008, 22:34

i was just looking for the equivelant of a print peek(address) command in asm.I wanted to print text and strings dumped from memory addresses.
... and that was exactly what was you got reply to. Now you may understand better, why asm programmers like HEX-numbers better. They are more easy to print. Smile

Is there an online tutorial that explains how to use bios routines in asm programs?
CALL <BIOS routine address>

Is there a good place for sources for those who just start to use asm?
I think http://map.tni.nl is the best place... It is not extremely good, but it is still the best... (You can also find descriptions of existing BIOS routines there) I suggest you to also download other peoples sources and learn from them.

By nikodr

Paladin (744)

nikodr's picture

18-03-2008, 23:12

i did this...this however does not seem to work as i wanted.The second line of text is never printed along with the number i placed on a...why?am i doing something wrong?I used tniasm to compile it.

;header initialize
fname "asm6.bin"
db 0feh
dw 0c800h,endadr,0c800h
ORG 0C800h

main:
ld HL,TEXT
call PRINT
ld HL,DECIMAL
ld a,243
call Calc8Dec
call PRINT
end:ret

;subroutine to print text on screen
PRINT: ld A,(HL)
inc HL
and A
jp Z,ENDPRINT
call CHPUT
jp PRINT
ENDPRINT: ret

TEXT: DB "HELLO this is like a print peek in asm",0
DECIMAL: DB "xxx...pretty easy!",0
CHPUT: EQU 0a2h
endadr: ret

Calc8Dec:
Calc8Dec2: ld c,48
Calc3DecLoop: sub 100
jr c,Calc3DecDone
inc c
jr Calc3DecLoop
Calc3DecDone: add a,100
ld (hl),c
inc hl
ld c,48
Calc2DecLoop:sub 10
jr c,Calc2DecDone
inc c
jr Calc2DecLoop
Calc2DecDone: add a,10
ld (hl),c
inc hl
ld c,48
Calc1DecLoop: sub 1
jr c,Calc1DecDone
inc c
jr Calc1DecLoop
Calc1DecDone:
ld (hl),c
Ret

By wolf_

Ambassador_ (9807)

wolf_'s picture

18-03-2008, 23:23

Haven't tested or anything (and who am I anyway? Tongue). but that Calc8Dec routine seems to destroy HL, hence you need to load the DECIMAL address into HL just before the 2nd PRINT call. (or otherwise work with push-ups and pops Tongue)

By nikodr

Paladin (744)

nikodr's picture

18-03-2008, 23:24

double post sorry!

By nikodr

Paladin (744)

nikodr's picture

18-03-2008, 23:32

now this seems to work in the sense that i doesnt crash yet it prints the second line 2 times and does not print any number
;header initialize
fname "asm6.bin"
db 0feh
dw 0c800h,endadr,0c800h
ORG 0C800h

main:
ld HL,TEXT
call PRINT

ld HL,DECIMAL
push hl ;i save hl
ld a,243 ;----------------> i suspect i have to actually save this?as the print routine uses accumulator also
call Calc8Dec
pop hl;i restore hl
call PRINT
end:ret

;subroutine to print text on screen
PRINT: ld A,(HL)
inc HL
and A
jp Z,ENDPRINT
call CHPUT
jp PRINT
ENDPRINT: ret

TEXT: DB "HELLO this is like a print peek in asm",0
DECIMAL: DB "xxx...pretty easy!",0
CHPUT: EQU 0a2h
endadr: ret

Calc8Dec:
Calc8Dec2: ld c,48
Calc3DecLoop: sub 100
jr c,Calc3DecDone
inc c
jr Calc3DecLoop
Calc3DecDone: add a,100
ld (hl),c
inc hl
ld c,48
Calc2DecLoop:sub 10
jr c,Calc2DecDone
inc c
jr Calc2DecLoop
Calc2DecDone: add a,10
ld (hl),c
inc hl
ld c,48
Calc1DecLoop: sub 1
jr c,Calc1DecDone
inc c
jr Calc1DecLoop
Calc1DecDone:
ld (hl),c
Ret

By MOA

Champion (293)

MOA's picture

19-03-2008, 00:07

Your 'endadr' (used in the BLOAD header) is not at the end of the source. The rest looks okay at first sight.

p/s: you don't have to save the accumulator. You don't need the value after converting it to decimal, do you?

By NYYRIKKI

Enlighted (5540)

NYYRIKKI's picture

19-03-2008, 00:13

No, no... Like this:

main:
ld HL,DECIMAL
ld a,243 
call Calc8Dec

ld HL,TEXT
jp PRINT 

- Remove the ",0" from end of TEXT: line
- move that endadr: to end of file

By wolf_

Ambassador_ (9807)

wolf_'s picture

19-03-2008, 00:15

mm skip the push/pop hl'ing.

Pushing and popping hl totals 21 cycles or something, ld hl,address only costs 10 cycles, hence, twice as fast. (But 1 byte more mem)

By nikodr

Paladin (744)

nikodr's picture

19-03-2008, 00:41

Nyyrikki and wolf thank you so much!After removing the 0 from the text it worked like a charm.

From what i understand the calc8dec goes to the address where DECIMAL is and places the converted integer data that has been ld a,243 in the place of the xxx,then after removing the 0 it makes it go and use the second line with the db too and print the data there?

cant wait to learn basic asm so i can go and make some more advanced stuff....Smile

Page 3/4
1 | 2 | | 4