WIN типа по дефолту, значит не переводить. В любом случае я проверил, при WIN ничего не происходит.
- - - Добавлено - - -
Я думаю можно сменить кодировку по умолчанию. Не пользуюсь VSCODE и тем более VS, но в моем саблайме все меняется достаточно просто. 1251 в качестве дефолтной это нормальная практика, нам же не нужны иероглифы.
sjasmplus binary doesn't contain all possible encodings and locales (and that's why it is ~300-500kB executable, not 15MB ).
the `ENCODING` directive is some one-way hack to do 866->1251 conversion or something like that, I'm NOT familiar with these encodings, and it's year+ since I was writing tests for it, so I'm not 100% sure if it has also some other way, but I'm 100% sure it has no idea what UTF8 is.
If you want to edit sources in UTF8, add to your build process conversion by some tool which knows all encodings, for example I did shorten your example to UTF8:
and saved that as "test_utf8.asm"Код:db "\N...или по-русски"
Then I can in linux do with `iconv` this:
(in my own project I would probably have special extension for all files with DB needing conversion like ".utf8.asm" and have implicit Makefile rule to convert those with iconv to ".1251.asm" and include from regular source those "something.1251.asm".Код:$ iconv -f utf8 -t cp1251 test_utf8.asm | sjasmplus - --msg=lst # file opened: console_input 1 0000 0A 2E 2E 2E db "\N...��� ��-������" 1 0004 E8 EB E8 20 1 0008 EF EE 2D F0 1 000C F3 F1 F1 EA 1 0010 E8 2 0011 # file closed: console_input
So then the build process would refresh them from the utf8 sources as needed, but sjasmplus would include the 1251 encoded ones ... but whatever works for you).
Why your VS/VSC doesn't remember encoding of project per file is kinda LOL, but I can't help with that, I don't use VS or VSC (in my favourite editor Kate I can open unknown file and it will try to auto-detect correct encoding, and if I manually switch it to correct encoding, it keeps the info in cache of recently opened files, so technically it will open with correct encoding forever on my local machine).
Есть задачка:
Определяем define appName "testapp"
этот define используется как в макросе (например):
MACRO newApp aName
db aName
ENDM
так и в пути при сохранении SAVEBIN
Собственно вопрос в том, как склеить 2 строки, что-то типа:
SAVEBIN "/dir1/dir2/dir3" + appName
Можно конечно с помощью LUA продефайнить ещё одну переменную:
LUA PASS1
appName = sj.get_define("appName")
print(appName)
savePath = ("install/bin/" .. appName)
print(savePath)
ENDLUA
Только вот результат в savePath будет install/bin/"testapp"
Не понятно какого фига приклеившиеся кавычки. Если их убрать в define, то Savepath правильный, но тогда падает сборка макроса, потому что «Can't found label testapp»
То есть без кавычек db почему-то хочет сохранить значение label? o_O вот же ж дичь.
И всё-таки походу пьесы в sjasmplus косяк.Нашёл решение.
Определяем без кавычек define appName testapp
В макросе добавляем кавычки с помощью LUA:
LUA ALLPASS
sj.insert_define("_appName", '"' .. sj.get_define("appName") .. '"')
_pc("db _appName")
ENDLUA
Тут вопрос закрыли. Далее формируем путь для сохранения файла:
LUA ALLPASS
sj.insert_define("SAVEPATH", '"install/bin/' .. sj.get_define("appName") .. '"')
ENDLUA
DISPLAY "SavePath:",/A,SAVEPATH
Тут всё отлично получаем наконец нормальную строку:
> SavePath:install/bin/testapp
Пытаемся сохранить:
SAVEBIN SAVEPATH, appStart, appEnd-appStart
Но! Savebin выдаёт мутную ошибку:
appTemplate.asm(141): error: Error opening file: install/bin/testapp
testApp.asm(48): ^ emitted from here
И что это хз. Если вместо SAVEPATH написать "install/bin/testapp" всё сохраняется на ура.
- - - Добавлено - - -
Хех, поэкспериментировав немного получил вообще оооочень странную картину:
Если при формировании SAVEPATH добавить в конец 1:
LUA ALLPASS
sj.insert_define("SAVEPATH", '"install/bin/' .. sj.get_define("appName") .. '1"')
ENDLUA
то ошибка вообще фантастическая, оказывается приклеивается туева хуча пробелов )))
И стало понятно, что это из-за комментария, в конце define, нельзя так делать XDКод:> SavePath:install/bin/testapp 1
Солюшен найден!Код:define appName testapp ; Краткое название приложения
Последний раз редактировалось breeze; 18.11.2021 в 13:07.
Как я понял достаточно?
Код:org 0x8000 define app appName LUA ALLPASS sj.insert_define("SAVEPATH", '"test/' .. sj.get_define("app") .. '.bin"') _pc ('db "'..sj.get_define("app")..'"') ENDLUA savebin SAVEPATH,0x8000,$-0x8000
those trailing spaces due to comment shouldn't happen since v1.18.2, so you are probably at older version of sjasmplus? It makes things easier when you specify version of sjasmplus when reporting some issue.
You can also trim/add quotes in lua script, but I never remember lua syntax from head, so I would have to google the lua tutorials to find the string operators and how to do it.
There also does exist:
It's not super smart and it can break quite easily too but it may cover some use cases, so in your case something like `--outprefix=/dir1/dir2/dir3/` would affect the `SAVEBIN appName` from first post (notice the trailing slash in the option). But it would affect also many other output commands, so not sure if this is helpful in your case.Код:--outprefix=<path> Prefix for save/output/.. filenames in directives
Let me know if I should produce some lua example doing also the quotes stripping/adding, maybe I even have it somewhere in tests, I think I recall something like that, but I'm not sure.
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.
Well, this is not really an issue, rather a flaw.
Well, I'll keep in mind. But in this situation, it is easier to move the comment to another line.
As a single solution yes, but I have a multi-assembly and may have different paths and filenames.
Okay, I'll try to implement this solution.
It would be very nice to get closer interaction between variables inside a macro and the results of LUA execution.
- - - Добавлено - - -
Есть ещё вопрос по макросам. Как получить длину передаваемой строки внутри макроса?
Например:
Длину строки можно получить с помощью LUA:Код:print "Loooooooong text string!" MACRO print text вот чему тут равна длина строки text? ENDM
string.len(text)
Но как получить доступ к переменной макроса?
Можно было бы временно сохранить с помощью:
DEFINE text_ text
и уже внутри LUA достучаться:
sj.get_define("text_")
но вместо значения переменной text, мы получаем просто слово «text».
Чёт прям замкнутый круг какой-то. Может есть какой-то спецсимволы, что бы передать значение?
Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)