ULM Assembler (Part 2: Code Generation)

Directives for Generating Data

1
2
3
4
5
6
    .space  8
    .string "foo"
    .byte   0x11
    .word   0x2211
    .long   0x44332211
    .quad   0x8877665544332211
theon$ ulmas data.s
theon$ 
#TEXT 8
0x0000000000000000: 00 00 00 00
0x0000000000000004: 00 00 00 00 #     .space 
0x0000000000000008: 66 6F 6F 00 #     .string "foo"
0x000000000000000C: 11 00 22 11 #     .byte 17 #      for alignment #     .word 8721
0x0000000000000010: 44 33 22 11 #     .long 1144201745
0x0000000000000014: 00 00 00 00 #      for alignment
0x0000000000000018: 88 77 66 55
0x000000000000001C: 44 33 22 11 #     .quad 9833440827789222417
#DATA 1
#BSS 1 0
#SYMTAB

Redefinition of Symbols with .equ

Some assemblers take the meaning of .equ as equivalent very serious. Once a symbol was defined to be equivalent to some expression you can not chnage that. The GNU assembler is more relaxed and so is the ULM assembler. It certainly would be better to treat .equ strictly as an equivalence, and provide a .sym directive that allows redefinition of symbols. Well, we live in a world were lots of things could be better.

1
2
3
4
5
    .data
    .byte   foo
    .equ    foo,    1
    .byte   foo
    .equ    foo,    2
theon$ ulmas equ.s
theon$ 

What would you expect is the value of the byte used in the first .byte directive (Line 2)?

#TEXT 4
#DATA 1
0x0000000000000000: 02 #     .byte foo
0x0000000000000001: 01 #     .byte foo
#BSS 1 0
#SYMTAB
a foo                  0x0000000000000002