User Tag List

Показано с 1 по 10 из 699

Тема: SjASMPlus от z00m

Комбинированный просмотр

Предыдущее сообщение Предыдущее сообщение   Следующее сообщение Следующее сообщение
  1. #1

    Регистрация
    22.05.2011
    Адрес
    г. Дзержинск, Украина
    Сообщений
    6,829
    Спасибо Благодарностей отдано 
    483
    Спасибо Благодарностей получено 
    663
    Поблагодарили
    513 сообщений
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от Ped7g Посмотреть сообщение
    Any info about that header checksum, how to calculate it?
    например

    Код:
    0000       Restart $00 Address
               (RST $00 calls this address.)
    0008       Restart $08 Address 
               (RST $08 calls this address.)
    0010       Restart $10 Address 
               (RST $10 calls this address.)
    0018       Restart $18 Address 
               (RST $18 calls this address.)
    0020       Restart $20 Address 
               (RST $20 calls this address.)
    0028       Restart $28 Address 
               (RST $28 calls this address.)
    0030       Restart $30 Address 
               (RST $30 calls this address.)
    0038       Restart $38 Address 
               (RST $38 calls this address.)
    
    0040       Vertical Blank Interrupt Start Address
    
    0048       LCDC Status Interrupt Start Address
    
    0050       Timer Overflow Interrupt Start Address
    
    0058       Serial Transfer Completion Interrupt 
               Start Address
    
    0060       High-to-Low of P10-P13 Interrupt 
               Start Address
    An internal information area is located at 0100-014F in
    each cartridge. It contains the following values:
    
    0100-0103  This is the begin code execution point in a
               cart. Usually there is a NOP and a JP
               instruction here but not always.
    
    0104-0133  Scrolling Nintendo graphic:
            CE ED 66 66 CC 0D 00 0B 03 73 00 83 00 0C 00 0D
            00 08 11 1F 88 89 00 0E DC CC 6E E6 DD DD D9 99
            BB BB 67 63 6E 0E EC CC DD DC 99 9F BB B9 33 3E
               ( PROGRAM WON'T RUN IF CHANGED!!!)
    
    0134-0142  Title of the game in UPPER CASE ASCII. If it
               is less than 16 characters then the
               remaining bytes are filled with 00's.
    
    0143       $80 = Color GB, $00 or other = not Color GB
    
    0144       Ascii hex digit, high nibble of licensee
               code (new).
    
    0145       Ascii hex digit, low nibble of licensee 
      code (new). (These are normally $00 if
               [$014B] <> $33.)
    
    0146       GB/SGB Indicator (00 = GameBoy, 03 = Super
               GameBoy functions)
               (Super GameBoy functions won't work 
               if <> $03.)
    
    0147       Cartridge type:
        0-ROM ONLY             12-ROM+MBC3+RAM
        1-ROM+MBC1             13-ROM+MBC3+RAM+BATT
        2-ROM+MBC1+RAM         19-ROM+MBC5
        3-ROM+MBC1+RAM+BATT    1A-ROM+MBC5+RAM
        5-ROM+MBC2             1B-ROM+MBC5+RAM+BATT
        6-ROM+MBC2+BATTERY     1C-ROM+MBC5+RUMBLE
        8-ROM+RAM              1D-ROM+MBC5+RUMBLE+SRAM
        9-ROM+RAM+BATTERY      1E-ROM+MBC5+RUMBLE+SRAM+BATT
        B-ROM+MMM01            1F-Pocket Camera
        C-ROM+MMM01+SRAM       FD-Bandai TAMA5
        D-ROM+MMM01+SRAM+BATT  FE - Hudson HuC-3
        F-ROM+MBC3+TIMER+BATT  FF - Hudson HuC-1
       10-ROM+MBC3+TIMER+RAM+BATT
       11-ROM+MBC3
    
    0148       ROM size:
                 0 - 256Kbit =  32KByte =   2 banks
                 1 - 512Kbit =  64KByte =   4 banks
                 2 -   1Mbit = 128KByte =   8 banks
                 3 -   2Mbit = 256KByte =  16 banks
                 4 -   4Mbit = 512KByte =  32 banks
                 5 -   8Mbit =   1MByte =  64 banks
                 6 -  16Mbit =   2MByte = 128 banks
               $52 -   9Mbit = 1.1MByte =  72 banks
               $53 -  10Mbit = 1.2MByte =  80 banks
               $54 -  12Mbit = 1.5MByte =  96 banks
    
    0149       RAM size:
               0 - None
               1 -  16kBit =  2kB = 1 bank
               2 -  64kBit =  8kB = 1 bank
               3 - 256kBit = 32kB = 4 banks
               4 -   1MBit =128kB =16 banks
    
    014A       Destination code:
               0 - Japanese
               1 - Non-Japanese
    
    014B       Licensee code (old):
               33 - Check 0144/0145 for Licensee code.
               79 - Accolade
               A4 - Konami
               (Super GameBoy function won't work 
               if <> $33.)
    
    014C       Mask ROM Version number (Usually $00)
    
    014D       Complement check
               (PROGRAM WON'T RUN ON GB IF NOT CORRECT!!!)
               (It will run on Super GB, however, 
               if incorrect.)
    
    014E-014F  Checksum (higher byte first) produced by
               adding all bytes of a cartridge except for
               two checksum bytes and taking two lower
               bytes of the result. (GameBoy ignores this
               value.)
    а так для тестирования в bgb
    можно загрузить любой .bin любого размера
    просто header заполнить 0
    а с его дебагера можно уже запустить с любого адреса

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

    http://bgb.bircd.org/
    Последний раз редактировалось NEO SPECTRUMAN; 28.09.2019 в 11:46.

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

  3. #2

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

    По умолчанию

    Цитата Сообщение от NEO SPECTRUMAN Посмотреть сообщение
    ...
    Ok, "--lr35902" added to sjasmplus. You can check the listing of the test to see which variants of syntax are supported and which not.
    https://github.com/z00m128/sjasmplus...tax_by_neo.lst

    I will add more tests in following days to verify all code paths, range checking, disabling of all Z80-only instructions, etc... but I did test the implementation a bit already while working on it, should be quite solid. I will need you to review also those new tests added later, but you can start by this first one...

    And ultimately it would be nice if you would try to actually build some working binary and confirm it works and sjasmplus is usable also for LR35902 programming...

    As mentioned before, the IDA disassembly + sjasmplus assembly may not produce identical binary due to ambiguity of such process, but you can patch the source with "db" to force sjasmplus emit identical binary in areas where it fails (it should fail only due to ambiguity = not bug, any other difference is bug of course).

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

    NEO SPECTRUMAN(30.09.2019)

  4. #3

    Регистрация
    22.05.2011
    Адрес
    г. Дзержинск, Украина
    Сообщений
    6,829
    Спасибо Благодарностей отдано 
    483
    Спасибо Благодарностей получено 
    663
    Поблагодарили
    513 сообщений
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    by default the sjasmplus understands "a," as multi-arg: "sub a,0" = "sub a : sub 0" (!)
    кстати это мне мешает и при писании под z80

    как по мне все "комбинированные" команды типа ld hl,0,bc,0,a,0,e,0
    это есть FAKE instructions
    и должны быть отключаемыми чтоб не мешали


    ага почитал инструкцию
    потом попробую поклацать `--syntax=a`

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

    Ped7g, так же возможно нужно выдавать предупреждение
    если после команд halt не стоит nop

    так как команда после halt по ошибке читается 2 раза
    однобайтная команда будет исполнена 2 раза подряд

    а 2-х 3-х байтная п

    76 halt
    fa 34 12 ld a,[1234]

    по идеи на gameboy-е превратится в

    76 halt
    fa fa 32 ld a,[12fa]
    12 ld [de],a


    хотя это явление можно использовать в своих целях
    Последний раз редактировалось NEO SPECTRUMAN; 30.09.2019 в 05:41.

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

    Ped7g(30.09.2019)

  5. #4

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

    По умолчанию

    Цитата Сообщение от NEO SPECTRUMAN Посмотреть сообщение
    так же возможно нужно выдавать предупреждение
    если после команд halt не стоит nop
    It repeats opcode only when `halt` is encountered in `DI` mode? (from what I have read, I have zero real experience) (contrary to ZX where such situation is total freeze - until NMI/reset).

    Anyway, this is something completely new in sjasmplus, to warn on instruction depending on the state from previous instruction. I understand it may be very handy, but I'm not sure if/how to add that. I will take a quick look, but I don't like this idea too much (it will be probably quite a mess to add)... in PC world of compilers this would be perfect case for lint-warning, not compiler. But there's no sjasmplus-lint ... yet? ...

    (actually would be maybe interesting to create a SW doing some static analysis of Z80 machine code and issue warnings about common probably-bug codes, although I personally would really rather like IDE which would support running pieces of code in head-less emulator and display the "live" results and/or use that for unit test... there is some effort from Maziac to build something like this for VS Code, but I'm avoiding anything from Microsoft, so I didn't try it yet (if you don't mind VSC used as base editor, then definitely check this: https://github.com/maziac/z80-unit-tests ... this is IMHO such a killer thing, that I'm actually thinking about trying it out, even if I will have to revoke my MS ban temporarily for VSC ... also I'm not sure how well it works in current version, but if it would be based on any other free editor, I would be already trying to help to develop it ... and such IDE running also the lint-tool in background ... you get the idea)

    So I will give it a quick look, but I'm afraid this will have no good place to land and it will not happen right now.

    -----

    Цитата Сообщение от NEO SPECTRUMAN Посмотреть сообщение
    кстати это мне мешает и при писании под z80
    well, yes, that was of the main goals why I did take a look into sjasmplus sources, to get rid of bugs from `ld a,(flag1|flag2)` and `sub a,5`. But both fixes are hidden under new `--syntax` option, so the sjasmplus is mostly backward compatible with 1.07 version (and I know I did break this compatibility already in many small details, but every now and then somebody search for some old intro/tool source compiled by 1.07, and almost always it works without any change, so I think I was 50% successful with this "don't break old sources" ... actually I'm growingly unhappy by how many things I did already break, and I don't want to break anything more right now, if anything else requires change in default behaviour, I'm postponing it to "v2.0" ... and that's uncertain, when it will happen, if ever)

    Anyway, I strongly suggest to use `--syntax=abfw` as default when writing new source (and probably patch old source to work with this setting too)... the "--syntax=abf" will be highly likely the syntax of v2.0 (and it will be mandatory in 2.0), so by using these already now your source will have higher chance to work in 2.0 without a change.

    If somebody reading this is not familiar what it is:
    "a" = multiarg delimiter is ",,", example `ld hl,1,,bc,2,,de,3 : sub a,c,,5,,a,,a,3` (the second is `sub c : sub 5 : sub a : sub 3`, the single vs double comma makes it possible for sjasmplus to tell which part is new `sub`, and which part is extra "a," like add/adc/sbc has)
    "b" = round parentheses (around whole expression) may be used only for memory acces `ld b,(4)` = error, `ld b,(2)+(2)` = ok, `ld b,+(4)` = ok
    "f" is producing warnings on all fake instructions (if you use some by accident)
    "w" is "warning as errors", so you will never miss any warning in the source

    There is also "B" option, which is my personal preference, that one enforces usage of square brackes for memory, so `ld a,(expr)` is always `ld a,imm8` and for memory you must use `ld a,[expr]`, so in my sources I'm planning to use rather `--syntax=aBfw`, but that will make them probably a bit incompatible with other people, so I'm still not sure.

    This whole --syntax option is sort of not that great idea, although I designed it together with OPT directive to work in a way where you can change syntax only temporarily for part of source and then "pop" back previous syntax options, so I can still write some library code for others, and use my options, and they can still include my source.

    Anyway, for people who don't like these more strict syntax things, and generally don't like any change, I want to leave v1.14.x in near-perfect state, so they can stick to it for decades... for people like me, who don't mind to fix the source and rather want more warnings/errors and stricter syntax, the v2.0 is planned...

  6. #5

    Регистрация
    22.05.2011
    Адрес
    г. Дзержинск, Украина
    Сообщений
    6,829
    Спасибо Благодарностей отдано 
    483
    Спасибо Благодарностей получено 
    663
    Поблагодарили
    513 сообщений
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от Ped7g Посмотреть сообщение
    It repeats opcode only when `halt` is encountered in `DI` mode? (from what I have read, I have zero real experience) (contrary to ZX where such situation is total freeze - until NMI/reset).

    Anyway, this is something completely new in sjasmplus,
    В принципе это не важно

    rgbasm (тот чей синтаксис по идеи применен в IDA)
    при компиляции halt

    генерирует сразу последовательность halt nop

    а ты потом сидишь и ищешь
    почему же дизассемблированный скомпилированный код не совпадает с оригиналом

  7. #6

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

    По умолчанию

    Цитата Сообщение от NEO SPECTRUMAN Посмотреть сообщение
    rgbasm (тот чей синтаксис по идеи применен в IDA) при компиляции halt генерирует сразу последовательность halt nop
    And I 100% don't want to go *there*. You can always create yourself:
    Код:
    halt MACRO
            @halt : nop
         ENDM
    (and emit only-halt by @halt" if you want to avoid the macro halt+nop on purpose)

    I feel this is not truly responsibility of assembler, IMHO it belongs to different stage of the pipeline. (showing warning is OK, that would make some sense, but emitting halt+nop instead of halt is just evil)

    I will give it quick look, but I don't expect this warning to become a reality (unless there already is good scaffolding for state between lines... thinking about it, there are few features working like that, for example IFUSED can follow non-local label on next line, and it will use the previous label, if there was no explicit one on the IFUSED line, so I will check how general/robust those mechanisms are, but I think it's just total mess like always, and adding halt+nop check would end as mess too ).

    edit: I think I by accident triggered the "mention" of user "ha", sorry!
    edit2: and I can't get rid of it, I don't know how to escape the @ to be used only as letter and not trigger the user-mention mechanism. Wow.. that may be lot of fun with sjasmplus sources...
    Последний раз редактировалось Ped7g; 30.09.2019 в 11:55.

  8. #7

    Регистрация
    22.05.2011
    Адрес
    г. Дзержинск, Украина
    Сообщений
    6,829
    Спасибо Благодарностей отдано 
    483
    Спасибо Благодарностей получено 
    663
    Поблагодарили
    513 сообщений
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от Ped7g Посмотреть сообщение
    I feel this is not truly responsibility of assembler
    у меня на макросах для sjasm написан chip8 компилятор
    он кидает кучу ошибок в процессе
    но на выходе код получается правильный
    и некоторые команды z80 там по моему вполне заменены командами chip8

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

    поддерживаемые команды
    Код:
    	8080 like	z80 like
    0***	sys ***
    00C*	scdown *	scd *
    00E0	cls
    00EE	rts		ret		rst тк при попытке напечатать rts часто получается именно так
    00FB	scright		scr
    00FC	scleft		scl
    00FD	exit
    00FE	low
    00FF	high
    1***	jmp ***		jp ***
    2***	jsr ***		call ***
    3x**	skeq vx,**	se vx,**
    4x**	skne vx,**	sne vx,**
    5xy0	skeq vx,vy	se vx,vy
    6x**	mov vx,**	ld vx,**
    7x**	add vx,**
    8xy0	mov vx,vy	ld vx,vy
    8xy1	or vx,vy
    8xy2	and vx,vy
    8xy3	xor vx,vy
    8xy4	add vx,vy
    8xy5	sub vx,vy
    8x06	shr vx				+ 8xx6 mode
    8xy7	rsb vx,vy	subn vx,vy
    8x0E	shl vx				+ 8xxE mode
    9xy0	skne vx,vy	sne vx.vy
    A***	mvi ***
    B***	jmi ***
    Cx**	rand vx,**	rnd vx,**
    Dxy*	sprite vx,vy,*	drw vx,vy,*
    Dxy0	xsprite vx,vy
    Ex9E	skpr vx		skp vx
    ExA1	skup vx		skpn vx
    Fx07	gdelay vx
    Fx0A	key vx
    Fx15	sdelay vx
    Fx18	ssound vx
    Fx1E	adi vx
    Fx29	font vx
    Fx30	xfont vx
    Fx33	bcd vx
    Fx55	str v0-vx
    Fx65	ldr v0-vx

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

    Ped7g(30.09.2019)

  9. #8

    Регистрация
    02.05.2015
    Адрес
    г. Таллин, Эстония
    Сообщений
    1,691
    Спасибо Благодарностей отдано 
    302
    Спасибо Благодарностей получено 
    223
    Поблагодарили
    159 сообщений
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от Ped7g Посмотреть сообщение
    IAnyway, this is something completely new in sjasmplus, to warn on instruction depending on the state from previous instruction.
    How you can find previous instruction, if HALT is reached after jump or call?
    Seems tracking previous instruction is only half of solution, and looks more like crutch.

  10. #9

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

    По умолчанию

    Цитата Сообщение от NEO SPECTRUMAN Посмотреть сообщение
    а что за stop e0 ? о_О
    I think I have catched a glimpse of some note about GBC using stop + value as mechanism to modify some console HW settings, but I may be wrong (and I don't care). Either way, the `stop` is two byte instruction in every decent description I have seen, suggesting the second byte is zero, so that is what `stop` does, but it has this optional argument which can override the zero byte to anything you want. Maybe it's useless/wrong, but shouldn't cause any harm, as normal usage is `stop` without argument = that will produce implicit zero. There is no way to produce short stop in sjasmplus (except "db $10"). I think anyone of need of these unofficial things knows how to deal with it without direct support? I guess.

    .... and I pushed to github final batch of tests I did plan to add, for me this feature is done. Waiting for bug reports...


    Цитата Сообщение от Bedazzle Посмотреть сообщение
    How you can find previous instruction, if HALT is reached after jump or call?
    Seems tracking previous instruction is only half of solution, and looks more like crutch.
    It's the other way, when assembling current line, I need to know that the previous instruction was `halt` and if the current instruction is not `nop`, a warning can be shown. Jumps/calls don't matter at all, as halt can't jump, so the next instruction after it will be executed, either in regular way, or with instruction opcode repeated (hw glitch of GB consoles), depending on the state of the machine when halt was reached. So `nop` is kinda only safe opcode after `halt` to fight this glitch back, unless you know precisely what you are doing and actually you want to use that glitch for some planned behaviour.

    Anyway, from the assembling point of view, it's all about some internal "flag" being set by `halt` and staying active for one next instruction, which is trivial to add as some global variable, which usually trivially decays into weird bugs like forgetting to clear it in certain code paths, etc... So I'm not in hurry to add it, maybe I will figure out something more elegant and easier to maintain later. (or maybe somebody else will write some static-analyzer/lint for Z80 machine code )

  11. #10

    Регистрация
    02.05.2015
    Адрес
    г. Таллин, Эстония
    Сообщений
    1,691
    Спасибо Благодарностей отдано 
    302
    Спасибо Благодарностей получено 
    223
    Поблагодарили
    159 сообщений
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от Ped7g Посмотреть сообщение
    It's the other way, when assembling current line, I need to know that the previous instruction was `halt` and if the current instruction is not `nop`, a warning can be shown.
    I mean it is not straightforward

    HALT
    DB 0

    ....

    DB 117+1
    NOP


    ....

    HALT
    AND A

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

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

Эту тему просматривают: 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

Ваши права

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