User Tag List

Страница 52 из 70 ПерваяПервая ... 484950515253545556 ... ПоследняяПоследняя
Показано с 511 по 520 из 699

Тема: SjASMPlus от z00m

  1. #511

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

    По умолчанию

    Цитата Сообщение от 0xDEAD Посмотреть сообщение
    Почему do not use
    I don't know. That comment is in the documentation since who-knows-when and no idea what the author had on mind.

    Цитата Сообщение от 0xDEAD Посмотреть сообщение
    отличается от
    The difference is that "SDOT.X" is internal structure offset, like +4 for example (checking now docs, it's actually +0 in docs example 6.2). "COLOR.GREEN" is instance of structure somewhere in memory, so it's address like 0x1234. ("SCOLOR.GREEN" is the one to not use directly, that's part of structure definition)

    I'm still confused what issue was author foreseeing and what improvements he had on mind, because as far as I can tell, there's nothing tricky about using the structure offset itself that way (except it makes little sense, why would you want to do `ld a,(SDOT.X)` .. to read ROM?)
    Even if you really want to read the data from ROM 0x0000 area, you can create "instance at address" like `ROMDOT SDOT = 0x0000` and use `ld a,(ROMDOT.X)` instead to avoid the offset label. (or ORG 0x0000 and instance SDOT after that).

    The warning is specifically about memory indirection "(address)", so `ld de,SDOT.X` is ok, no issue with that. But right now in current sjasmplus `ld de,(SDOT.X)` will work too, assembling as `ld de,(0)`. Maybe the original author did plan to add some warning in such case, to make sure you didn't forget `ix+` or something like that?

    I don't know.

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

  3. #512

    Регистрация
    18.07.2021
    Адрес
    г. Хмельницкий, Украина
    Сообщений
    105
    Спасибо Благодарностей отдано 
    12
    Спасибо Благодарностей получено 
    33
    Поблагодарили
    25 сообщений
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    In two words: can I use something like ld a,(COLOR.GREEN), or even like LD A,(SDOT.X) (!) in my code to get access to the strucrure's members, or not? I am confused.
    Does it means that using ld de,(SDOT.X), i will not get in DE value of SDOT.X label pointed to, but, instead, value of (0)?

    Tested it, at last, and it seems, it works as it should be: ld (label.field), a writes smtg to memory and ld a, (label.field) reads from it. No idea, what that warning means, but ok.
    Последний раз редактировалось 0xDEAD; 03.10.2021 в 22:04.

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

    Ped7g(03.10.2021)

  4. #513

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

    По умолчанию

    Цитата Сообщение от 0xDEAD Посмотреть сообщение
    can I use something like ld a,(COLOR.GREEN)
    you can use currently any of those symbols in all possible ways, it will get assembled "correctly", but using the structure offset as absolute address is probably not what you want, sounds like bug in your logic.

    I tried to prepare example about basic usage of STRUCT (it has more extended stuff, but this should be enough to illustrate what the docs warning is about):
    Код:
    ; structure definition (ie. like "struct" in C, defining structure)
        STRUCT SCOLOR
    RED     BYTE    4       ; offset 0
    GREEN   BYTE    5       ; offset 1
    BLUE    BYTE    6       ; offset 2
        ENDS
    
        STRUCT SDOT
    ID      WORD    0       ; offset 0
    C       SCOLOR  0,0,0   ; offset 2
    X       BYTE    0       ; offset 5
    Y       BYTE    0       ; offset 6
        ENDS
    
    ; this will assemble the same way as if you did define these symbols by EQU:
    ; (but sjasmplus will also remember default values of fields to create instances)
    ; (that part can't be replicated by EQU, only the symbol definitions)
    
    ; SCOLOR.RED      EQU 0x0000
    ; SCOLOR.GREEN    EQU 0x0001
    ; SCOLOR.BLUE     EQU 0x0002
    ; SCOLOR          EQU 0x0003    ; length of SCOLOR struct
    
    ; SDOT.ID         EQU 0x0000
    ; SDOT.C          EQU 0x0002    ; offset of SCOLOR struct inside SDOT struct
    ; SDOT.C.RED      EQU 0x0002
    ; SDOT.C.GREEN    EQU 0x0003
    ; SDOT.C.BLUE     EQU 0x0004
    ; SDOT.X          EQU 0x0005
    ; SDOT.Y          EQU 0x0006
    ; SDOT            EQU 0x0007    ; length of SDOT struct
    
    ; after structures are defined, you can create instances of them in memory
            ORG     $8000
    myDot   SDOT    {0x1234, {11, 22, 33}, 44, 55}  ; defines "myDot" with ID 0x1234, X=44, Y=55, and C=[11,22,33]
    
    ; using it in code
            ld      ix,myDot        ; address of instance
            ld      c,(ix+SDOT.C.GREEN)     ; C = 22 ; assembles as "ld c,(ix+3)"
            ld      a,(myDot.C.BLUE)        ; A = 33 ; assembles as "ld a,(0x8004)"
            ld      de,SDOT.X               ; DE = 5 ; offset inside SDOT struct to field X
            ld      de,(myDot.X)            ; E = 44, D = 55 ; "ld de,(0x8005)"
                        ; ^ this is using instance myDot label, not structure offset
    
    ; what docs warns against:
            ld      de,(SDOT.X)             ; ld de,(0x0005) -> reading ROM
            ; but this doesn't make lot of sense, as you are reading memory from offset
            ; so it looks rather like bug, like missing "ix+", for example:
            ld      e,(ix+SDOT.X)
            ld      d,(ix+SDOT.Y)           ; here using the +5 and +6 offsets makes sense
    Try to build this with listing: sjasmplus --lst --lstlab example.asm
    and check the symbol table and machine code emitted, hopefully this will make more sense.
    Последний раз редактировалось Ped7g; 03.10.2021 в 22:35.

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

    0xDEAD(03.10.2021)

  5. #514

    Регистрация
    18.07.2021
    Адрес
    г. Хмельницкий, Украина
    Сообщений
    105
    Спасибо Благодарностей отдано 
    12
    Спасибо Благодарностей получено 
    33
    Поблагодарили
    25 сообщений
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Who would use definition of structure in indirect addressing instead of declared one? But, who knows...
    This was the source of my misunderstanding. Everything is clear now, thanks!

  6. #515

    Регистрация
    27.02.2005
    Адрес
    Белоруссия
    Сообщений
    398
    Спасибо Благодарностей отдано 
    22
    Спасибо Благодарностей получено 
    21
    Поблагодарили
    14 сообщений
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Возможно ли реализовать передачу макросу строки в кавычках в качестве параметра или одного из параметров?

    Пример применения
    macroname "textstring"

    macro macroname str
    db ...some code...
    db str
    db ...some code...
    endm
    Your life is REAL. Change it UNREAL!

  7. #516

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

    По умолчанию

    Цитата Сообщение от transman Посмотреть сообщение
    Возможно ли реализовать передачу макросу строки в кавычках в качестве параметра или одного из параметров?
    да

    Код:
    $ sjasmplus --msg=lst -
        macro macroname str
            db 1,2,3
            db str
            db 3,2,1
        endm
    
        macroname "textstring"
    # file opened: console_input
    1     0000                  macro macroname str
    2     0000 ~                    db 1,2,3
    3     0000 ~                    db str
    4     0000 ~                    db 3,2,1
    5     0000                  endm
    6     0000
    7     0000                  macroname "textstring"
    7     0000 01 02 03    >        db 1,2,3
    7     0003 74 65 78 74 >        db "textstring"
    7     0007 73 74 72 69 >
    7     000B 6E 67       >
    7     000D 03 02 01    >        db 3,2,1
    8     0010
    # file closed: console_input
    (should be working in all versions I remember, but to create the example output above I did use 1.18.3)

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

    Bedazzle(25.10.2021), transman(26.10.2021)

  8. #517

    Регистрация
    17.08.2018
    Адрес
    г. Зеленодольск
    Сообщений
    3
    Спасибо Благодарностей отдано 
    1
    Спасибо Благодарностей получено 
    0
    Поблагодарили
    0 сообщений
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Здравствуйте!
    Возможно ли использовать макро для загрузки регистров?
    Например:
    ld de, macroname 8084h
    или
    defw macroname 80A0h

    Очень нужно реализовать что-то подобное, чтобы универсально править портируемые исходники.
    Спасибо.

  9. #518

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

    По умолчанию

    Цитата Сообщение от Weclemans Посмотреть сообщение
    Возможно ли использовать макро для загрузки регистров?
    unfortunately not, defining new functions is not possible. Macros could be used only in place of instructions, ie:
    Код:
      macro macroname instruction?, value?
        instruction? value?
      endm
    
      ; usage
      macroname <ld de,>, 8084h  ; will produce  "ld de,8084h"
      macroname defw, 80A0h  ; will produce "defw 80A0h"

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

    Weclemans(01.11.2021)

  10. #519

    Регистрация
    17.08.2018
    Адрес
    г. Зеленодольск
    Сообщений
    3
    Спасибо Благодарностей отдано 
    1
    Спасибо Благодарностей получено 
    0
    Поблагодарили
    0 сообщений
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Цитата Сообщение от Ped7g Посмотреть сообщение
    unfortunately not, defining new functions is not possible. Macros could be used only in place of instructions, ie:
    Код:
      macro macroname instruction?, value?
        instruction? value?
      endm
    
      ; usage
      macroname <ld de,>, 8084h  ; will produce  "ld de,8084h"
      macroname defw, 80A0h  ; will produce "defw 80A0h"
    Oh yeah, that's good option, too. Thanks a lot.

    P.S. Hmm, how about a harder example?
    ld (804Ah), a
    Последний раз редактировалось Weclemans; 01.11.2021 в 10:11. Причина: postscriptum

  11. #520

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

    По умолчанию

    not in direct way.

    You can do macro which will EQU some global value, and use that in code, then you have something somewhat like function macro.

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

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

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

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

Ваши права

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