User Tag List

Страница 55 из 70 ПерваяПервая ... 515253545556575859 ... ПоследняяПоследняя
Показано с 541 по 550 из 699

Тема: SjASMPlus от z00m

  1. #541

    Регистрация
    31.01.2007
    Адрес
    Москва
    Сообщений
    810
    Спасибо Благодарностей отдано 
    11
    Спасибо Благодарностей получено 
    77
    Поблагодарили
    59 сообщений
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Не совсем понятен общий вид, но вообще длину данных можно узнать
    Код:
    			org	0x8000
    			macro ma1 parm1
    temp			= $
    			db	parm1
    tlen			= $-temp
    			org	temp
    			db	tlen,parm1
    			endm
    			ma1	"test"
    			savebin	"test.bin", 0x8000,$-0x8000

    Этот пользователь поблагодарил krt17 за это полезное сообщение:

    breeze(19.11.2021)

  2. #541
    С любовью к вам, Yandex.Direct
    Размещение рекламы на форуме способствует его дальнейшему развитию

  3. #542

    Регистрация
    11.02.2005
    Адрес
    【RB】
    Сообщений
    3,877
    Спасибо Благодарностей отдано 
    130
    Спасибо Благодарностей получено 
    131
    Поблагодарили
    81 сообщений
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от krt17 Посмотреть сообщение
    Не совсем понятен общий вид, но вообще длину данных можно узнать
    Код:
                org    0x8000
                macro ma1 parm1
    temp            = $
                db    parm1
    tlen            = $-temp
                org    temp
                db    tlen,parm1
                endm
                ma1    "test"
                savebin    "test.bin", 0x8000,$-0x8000
    Жоска Но вечером попробую эту идею.

  4. #543

    Регистрация
    10.05.2019
    Адрес
    Prague, Czech Republic
    Сообщений
    229
    Спасибо Благодарностей отдано 
    51
    Спасибо Благодарностей получено 
    103
    Поблагодарили
    77 сообщений
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от breeze Посмотреть сообщение
    nop. SjASMPlus Z80 Cross-Assembler v1.18.3
    I think it physically cannot detect trailing spaces, since the text in this case is not in quotes.
    I'm really failing to replicate this:
    Код:
    ped@ped7g-sb:~$ sjasmplus-1.18.3 --version
    SjASMPlus Z80 Cross-Assembler v1.18.3 (https://github.com/z00m128/sjasmplus)
    ped@ped7g-sb:~$ sjasmplus-1.18.3 - --msg=lst
        define    appName testapp                    ; Краткое название приложения
        LUA ALLPASS
            sj.insert_define("SAVEPATH", '"install/bin/' .. sj.get_define("appName") .. '1"')
        ENDLUA
        db SAVEPATH
    # file opened: console_input
    1     0000                  define    appName testapp                    ; Краткое название приложения
    2     0000                  LUA ALLPASS
    3     0000 ~                    sj.insert_define("SAVEPATH", '"install/bin/' .. sj.get_define("appName") .. '1"')
    4     0000                  ENDLUA
    5     0000 69 6E 73 74      db "install/bin/testapp1"
    5     0004 61 6C 6C 2F
    5     0008 62 69 6E 2F
    5     000C 74 65 73 74
    5     0010 61 70 70 31
    6     0014
    # file closed: console_input
    I know this is not important for you, but makes me wonder what is happening and if there is some other bug in sjasmplus, that's why I'm poking into this detail. The trailing spaces should be now removed from DEFINEs. Maybe you have the DEFINE in some other code path like IF/ENDIF block or inside MACRO, or I don't know... interesting. If you will find some time, can you try to produce full example where v1.18.3 fails to remove the trailing space? Thank you.

    About string operators in sjasmplus - there are none, unfortunately. For any complex string manipulation the best way is to use lua script. The hack to figure out length by `ORG` macro is usable when in DEVICE mode, but would ruin the output in raw/OUTPUT mode (although you can open OUTPUT file for rewrite and rewind position back, I would probably rather opt for lua solution instead).

    Macro arguments to lua -> definitely possible, there is some test/example somewhere... Check this test in particular and whole folder "lua_examples" and maybe also "macro_examples": https://github.com/z00m128/sjasmplus...macro_arg2.asm
    Not sure if it will answer all your questions/issues, but maybe you will be able to pick up some trick or two.

    I'm following this conversation a bit half-minded as I'm focusing on some work stuff, so in case you are waiting for some example from me or you are stuck with final version of your attempt, post that as new post clearly saying you expect specific help from me, otherwise I may miss it (right now I think you are trying to resolve it all yourself, so I'm giving you just pointers where to look, not preparing any full example).

    EDIT: actually going through that example, that's not useful for string manipulation... the older https://github.com/z00m128/sjasmplus..._macro_arg.asm is then probably more relevant, but I'm still not sure how well the string is passed through, I would have to write some actual code and test it to be 100% sure how it works. "It should be possible" is all I can say at this moment.
    Последний раз редактировалось Ped7g; 19.11.2021 в 14:31.

  5. #544

    Регистрация
    31.01.2007
    Адрес
    Москва
    Сообщений
    810
    Спасибо Благодарностей отдано 
    11
    Спасибо Благодарностей получено 
    77
    Поблагодарили
    59 сообщений
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от breeze Посмотреть сообщение
    Жоска
    Да я сам не люблю переставлять орг, по мне сам device режим это убожество.
    В принципе нормально работает и так
    Код:
    			org	0x8000
    			db	tend -$-1
    			db	"test"
    tend
    			savebin	"test.bin", 0x8000,$-0x8000
    Нужно по обстановке смотреть. Просто помнить что = можно в макросах, а просто метки и equ нельзя.

    Этот пользователь поблагодарил krt17 за это полезное сообщение:

    Ped7g(19.11.2021)

  6. #545

    Регистрация
    10.05.2019
    Адрес
    Prague, Czech Republic
    Сообщений
    229
    Спасибо Благодарностей отдано 
    51
    Спасибо Благодарностей получено 
    103
    Поблагодарили
    77 сообщений
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от krt17 Посмотреть сообщение
    Просто помнить что = можно в макросах, а просто метки и equ нельзя.
    uhm... what exactly is not possible about labels in macros?
    Regular label means the macro can be emitted only once (second emit would create duplicate label, at least in the same module), but you can define normal label in macro *once* (per module).

    The local labels inside macro are automatically per-instance so every use of macro has its own independent labels.

    And since v1.18.3 you can create non-macro local labels from inside macro by using "@" prefix ( https://github.com/z00m128/sjasmplus...cal_labels.asm ):
    Код:
      macro test
    @.kip3      ; prevent macro-local label and create regular local label instead
    kip0
    .kip1
    @.kip2
      endm
    
      module main
        ; should produce labels: main.hoi, main.kip0, 0>kip1, main.kip0.kip2, main.hoi.kip3
    hoi test
      endmodule
    resulting listing:
    Код:
    # file opened: local_labels.asm
     1    0000                macro test
     2    0000 ~            @.kip3      ; prevent macro-local label and create regular local label instead
     3    0000 ~            kip0
     4    0000 ~            .kip1
     5    0000 ~            @.kip2
     6    0000                endm
     7    0000
     8    0000                module main
     9    0000                  ; should produce labels: main.hoi, main.kip0, 0>kip1, main.kip0.kip2, main.hoi.kip3
    10    0000              hoi test
    10    0000             >@.kip3      ; prevent macro-local label and create regular local label instead
    10    0000             >kip0
    10    0000             >.kip1
    10    0000             >@.kip2
    11    0000                endmodule
    12    0000
    # file closed: local_labels.asm
    
    Value    Label
    ------ - -----------------------------------------------------------
    0x0000 X 0>kip1ing 
    0x0000 X main.hoi
    0x0000 X main.hoi.kip3
    0x0000 X main.kip0
    0x0000 X main.kip0.kip2
    So, labels in macros is just another available tool, should "work". It has somewhat specific rules and outcome, being affected by "inside macro", but I hope those rules are reasonably simple and usable.

    If you have source where labels inside macros don't work as designed, let me know, then it may be bug or misunderstanding and we can usually resolve that together.

    I'm not so into changing the rules, because every time I did some "fix" since 1.10.4 to today and the fix did some slight modification of old behaviour, even if technically it is now more correct, there are always some users with project which gets broken and requires fixing, and that's very annoying (sorry guys). So I'm trying hard to keep original behaviour and do only "fixes" and "extensions", if possible. But the current syntax of sjasmplus is quite powerful, like 7/10 IMHO. There're some things I would design a bit differently, if I was starting from scratch a new assembler. And there are definitely things I would implement differently. But overall the decent base quality was one of the reasons, why I did start fixing and extending sjasmplus, it was already quite good, just a bit bugged... (just my personal opinion, and I don't care if other people prefer other assembler, I just tried to make sjasmplus viable option)

    edit: not even sure what I was trying to say with that last paragraph... I think the main point is:
    reporting your issues and bugs with sjasmplus is welcome. I can't promise to answer/fix/extend everything as quickly as you need it, but I like to see sjasmplus used in your projects, so I will usually try to find some solution, if you have problem.
    Последний раз редактировалось Ped7g; 19.11.2021 в 19:31.

  7. #546

    Регистрация
    11.02.2005
    Адрес
    【RB】
    Сообщений
    3,877
    Спасибо Благодарностей отдано 
    130
    Спасибо Благодарностей получено 
    131
    Поблагодарили
    81 сообщений
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Exclamation

    Цитата Сообщение от Ped7g Посмотреть сообщение
    I'm really failing to replicate this:
    Aw **** here we go again =)

    Код:
    	DEVICE ZXSPECTRUM128
    
    
    	org	#8000
    
    
    appStart
    
    
    	define	appName    cursor				; comment
    
    
    	LUA ALLPASS
    		sj.insert_define("SAVEPATH", '"install/bin/' .. sj.get_define("appName") .. '"')
    	ENDLUA
    
    
    	db SAVEPATH
    
    
    appEnd
    
    
    	SAVEBIN "test.bin", appStart, appEnd-appStart
    result:

    Код:
    sjasmplus.exe test.asm --lst=test.lst
    SjASMPlus Z80 Cross-Assembler v1.18.3 (https://github.com/z00m128/sjasmplus)
    Pass 1 complete (0 errors)
    Pass 2 complete (0 errors)
    Pass 3 complete
    Errors: 0, warnings: 0, compiled: 17 lines, work time: 0.015 seconds
    test.lst

    Код:
    # file opened: test.asm
     1    0000              	DEVICE ZXSPECTRUM128
     2    0000
     3    0000              	org	#8000
     4    8000
     5    8000              appStart
     6    8000
     7    8000              	define	appName    cursor				; comment
     8    8000
     9    8000              	LUA ALLPASS
    10    8000 ~            		sj.insert_define("SAVEPATH", '"install/bin/' .. sj.get_define("appName") .. '"')
    11    8000              	ENDLUA
    12    8000
    13    8000 69 6E 73 74  	db "install/bin/   cursor				"
    13    8004 61 6C 6C 2F
    13    8008 62 69 6E 2F
    13    800C 20 20 20 63
    13    8010 75 72 73 6F
    13    8014 72 09 09 09
    13    8018 09
    14    8019
    15    8019              appEnd
    16    8019
    17    8019              	SAVEBIN "test.bin", appStart, appEnd-appStart
    # file closed: test.asm
    now also got trailing space before appName =)

    Этот пользователь поблагодарил breeze за это полезное сообщение:

    Ped7g(20.11.2021)

  8. #547

    Регистрация
    10.05.2019
    Адрес
    Prague, Czech Republic
    Сообщений
    229
    Спасибо Благодарностей отдано 
    51
    Спасибо Благодарностей получено 
    103
    Поблагодарили
    77 сообщений
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    ahh... ok... now it makes sense to *me*...

    The space ahead is intentional, I don't expect value to be indented, so only one space is removed and following space is considered define value.
    But the trailing stuff is tab vs space, I have space-as-tabs everywhere, and seems I forgot to test the trailing space trimming with tabulators...

    I will take a look on it. (and I know the leading space preservation is not intuitive, but I'm not sure what to do about it... it's a bit unclear. In macro arguments I guess it's safe to trim everything, because you can use `<>` syntax to enclose argument value which contains leading/trailing space, but in DEFINE there's no delimiter syntax, everything is just new value for DEFINE (the trailing space trimming is a bit dubious extra, but nobody objected about it so far).

    edit: or maybe I will just add to docs that DEFINE and macro arguments trim whitespace (and fix the code), and there will be no possible way to set up DEFINE value with leading/trailing white space.
    Последний раз редактировалось Ped7g; 20.11.2021 в 17:05.

  9. #548

    Регистрация
    11.02.2005
    Адрес
    【RB】
    Сообщений
    3,877
    Спасибо Благодарностей отдано 
    130
    Спасибо Благодарностей получено 
    131
    Поблагодарили
    81 сообщений
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    @Ped7g is it possible access to DEFARRAY's element from LUA?

  10. #549

    Регистрация
    10.05.2019
    Адрес
    Prague, Czech Republic
    Сообщений
    229
    Спасибо Благодарностей отдано 
    51
    Спасибо Благодарностей получено 
    103
    Поблагодарили
    77 сообщений
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от breeze Посмотреть сообщение
    is it possible access to DEFARRAY's element from LUA?
    Hmm, had to look into source, but unfortunately, not.
    If it is numeric value (32bit int result), you can at least evaluate it through `_c("test_array[2]")`, but if you need string, I was unable to find any decent workaround. I tried also some trick to define single temporary define from one element, but that doesn't substitute during evaluation the way how it would be needed for lua script.

  11. #550

    Регистрация
    11.02.2005
    Адрес
    【RB】
    Сообщений
    3,877
    Спасибо Благодарностей отдано 
    130
    Спасибо Благодарностей получено 
    131
    Поблагодарили
    81 сообщений
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Exclamation

    @Ped7g and AGAin very strange problem

    Код:
                    db_u    "Test"
    
                    macro db_u text
            define _t text
                    lua allpass
                             local str = sj.get_define("_t")
                             print(type(str))
                             print(str)
                             str = str:gsub(".?$","")
                             str = str:gsub("^.?","")
                             print(str)
                    endlua
            undefine _t
                    endm
    Got error — (16): error: [LUA] attempt to call global 'gsub' (a nil value)

    16 line → str = str:gsub("^.?","")

    But if i add ; in begin like:

    Код:
                    ; str = str:gsub(".?$","")
                    ; str = str:gsub("^.?","")
    no error:

    Код:
    SjASMPlus Z80 Cross-Assembler v1.18.3 (https://github.com/z00m128/sjasmplus)
    string
    "Test"
    Test
    Pass 1 complete (0 errors)
    string
    "Test"
    Test
    Pass 2 complete (0 errors)
    string
    "Test"
    Test
    WTF????

    - - - Добавлено - - -

    Solution found

    replace code in style LUA 5.3:


    Код:
    str = string.gsub(str, ".?$","")
    str = string.gsub(str, "^.?","")
    Poof! and error was gone!
    Последний раз редактировалось breeze; 28.11.2021 в 12:23.

Страница 55 из 70 ПерваяПервая ... 515253545556575859 ... ПоследняяПоследняя

Информация о теме

Пользователи, просматривающие эту тему

Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)

Похожие темы

  1. SjASMPlus Z80 кросс ассемблер
    от Aprisobal в разделе Программирование
    Ответов: 1663
    Последнее: 19.06.2021, 01:36
  2. Исходники TR-DOS для SjASMPlus
    от Keeper в разделе Программирование
    Ответов: 20
    Последнее: 11.02.2011, 11:57
  3. Запуск STS из .sna, сгенерированного sjasmplus.
    от siril в разделе Программирование
    Ответов: 7
    Последнее: 11.10.2010, 21:33
  4. Breakpoints в связке Sjasmplus+UnrealSpeccy
    от Kurles в разделе Программирование
    Ответов: 19
    Последнее: 26.01.2009, 12:36
  5. Disturbed COverMAnia ( music disk with z00m music collection)
    от kyv в разделе Музыка
    Ответов: 10
    Последнее: 27.03.2008, 10:01

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •