简体   繁体   中英

Assembly: Organizing long segments of varied data

I am programming a game in assembly and I am wondering if there is a way to mix variable lengths on one line, in the way that you can define many variables of the same length in one line. Here's an example:

.Sprites:
    db $0f,120,39,$D506E3

This example fails on the last number in that list since it is not one byte. But this:

.Sprites:
    dl $0f,120,39,$D506E3

compiles and inserts empty space between the variables. The reason I want to be able to vary the size is because this will be a table with many sprites, and each one has the same format, so it would be better to leave each one's data on one line than to use two lines that could be confused:

.Sprites:
    ?? $0f,120,39,$D506E3
    ?? $0b,110,39,$D5001C
    ?? $01,120,36,$D509A1

I solved this issue by making a macro in fasmg .

macro sprite? color*,x*,y*,spriteID*
    db color
    dw x
    db y
    dd spriteID
end macro

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM