flat assembler
Message board for the users of flat assembler.

Index > DOS > How to do a concatenation ?

Author
Thread Post new topic Reply to topic
vanzan



Joined: 27 Apr 2010
Posts: 14
vanzan
Hi !

For my IT games project (an ASCII Arkanoid), I can not generate a string from multiple concatenation.

In fact, I try to generate a string containing the path of the level of the game from a variable "Level"

So if Level = 9 String = "data/lvl/lvl_0009.bw"
if Level = 133 String = "data/lvl/lvl_0133.bw"
etc. ...


Can you help me please ?




Rolling Eyes Rolling Eyes
Post 08 Jun 2010, 05:58
View user's profile Send private message Reply with quote
nop



Joined: 01 Sep 2008
Posts: 165
Location: right here left there
nop
maybe something like:
Code:
set_string_level:               ;enter with binary level in ax (max 9999 decimal)
push ds
push cs
pop ds
cmp ax, 9999
ja error
call bin2bcd                     ;returns 4 bcd digits in eax
call bcd2ascii                   ;returns 4 ascii chars in eax
mov [string_number],eax
pop ds
ret

string:
db "data/lvl/lvl_"
string_number:
dd 0
string_end:
db ".bw"
string_delimiter:              ;if needed
db 0
    

now you just need to code bin2bcd and bcd2ascii Very Happy
or maybe there's a better way?
Post 08 Jun 2010, 07:06
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
vanzan,
Code:
        org     0x100
        mov     ax, [Level]
        mov     di, name.level
        call    convert0000
        mov     dx, name                ; output to test it
        mov     ah, 9
        int     0x21
        ret

convert0000:
        mov     cl, 100
        div     cl
        mov     cl, ah
        call    convert00
        mov     al, cl
convert00:
        aam
        or      ax, '00'
        xchg    al, ah
        stosw
        ret

Level   dw      9876
name    db      "data/lvl/lvl_"
.level  db      "0000.bw", 13, 10, '$'; for int21/09    
Post 08 Jun 2010, 07:15
View user's profile Send private message Reply with quote
vanzan



Joined: 27 Apr 2010
Posts: 14
vanzan
The code seems to be correct but it doesn't work...

(3) wrong parameters: MOV bx, name.llevel
(3) probably no zero prefix for hex; or no 'h' suffix; or wrong addressing; or undefined var: name.llevel

I don't understand the syntax "name.llevel"...
Post 08 Jun 2010, 07:32
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
vanzan,

This is FASM board. Are you compiling with FASM? Wink
Post 08 Jun 2010, 07:38
View user's profile Send private message Reply with quote
vanzan



Joined: 27 Apr 2010
Posts: 14
vanzan
With emu8086, we had to use it for our project.

But it's a FASM compiler, isn't it ? (FASM v1.64)
Post 08 Jun 2010, 07:48
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
vanzan wrote:
With emu8086, we had to use it for our project.

But it's a FASM compiler, isn't it ? (FASM v1.64)
Not exactly. Some extensions are used, for example name directive from TASM Ideal mode. Prepend #fasm# line and change name to e.g. _name, it will compile fine.
Post 08 Jun 2010, 08:21
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
just say to your teacher that emu8086 is pure shit and that nowadays, fasm(w)(d) is the better choice to learn PC assembly.
Post 08 Jun 2010, 10:19
View user's profile Send private message Visit poster's website Reply with quote
vanzan



Joined: 27 Apr 2010
Posts: 14
vanzan
I totally agree with you but I don't have any choice... Rolling Eyes
Post 08 Jun 2010, 10:35
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
you always have the choice.
it is up to you to show the ease of use of new asm compilers to your teacher... i suppose he(she) impose emu8086 to you because he(she) don't know anything else...
Post 08 Jun 2010, 11:08
View user's profile Send private message Visit poster's website Reply with quote
vanzan



Joined: 27 Apr 2010
Posts: 14
vanzan
No, we HAVE to use emu8086... Even if it's a very old architecture, we used it in order to learn assembly.

I've already asked him if I could change the compilers but NO, we have to use it....

PS: in french : Mon école est assez rigide sur le sujet, bon nombre d'autres groupes (qui avaient commencé sur d'autres langages comme RadASM, MASM,...) ont du recommencer leur projet sous peine d'avoir 1 zero.
Post 08 Jun 2010, 11:23
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
je prefere avoir un zero pointé que d'utiliser un truc inutile. emu 8086 est un truc inutile, totallement inutile, bon pour les profs sclerosés qui vraiment ne connaissent rien d'autre que leurs bonnes vieilles methodes obsoletes.

je serait à ta place, je prendrai un zero(en codant le truc avec QBASIC), et en plus, j'essayerai d'effacer toute trace d'emu8086 des pc du college (ou lycée).
Post 08 Jun 2010, 14:44
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.