-BITS 32
+[BITS 32]
[MAP all]
; This file is loaded as a DOS .COM file.
-SEGMENT _TEXT start=0 vstart=100h
+[SEGMENT _TEXT start=0 vstart=100h]
; shrink & relocate stack:
mov sp, stack_ends ; NASM puts 460h here -
mov ah, 4Ah ; DOS resize mem.block
int 21h
-SEGMENT GATESEG align=1 follows=_TEXT vstart=0
+[SEGMENT GATESEG align=1 follows=_TEXT vstart=0]
; label to use for copying this segment at run-time.
gate0cpy:
dd 0
; vstart=0 makes some calculations easier.
; Reserve space for stack:
-SEGMENT .bss follows=GATESEG align=16
+[SEGMENT .bss follows=GATESEG align=16]
resb 400h
stack_ends:
; [16] Reference a data-section symbol in the data section
; [17] Reference a BSS-section symbol in the data section
- BITS 64
- GLOBAL lrotate:function ; [1]
- GLOBAL greet:function ; [1]
- GLOBAL asmstr:data asmstr.end-asmstr ; [2]
- GLOBAL textptr:data 4 ; [2]
- GLOBAL selfptr:data 4 ; [2]
- GLOBAL integer:data 4 ; [3]
- EXTERN printf ; [10]
- COMMON commvar 4:4 ; [7]
- EXTERN _GLOBAL_OFFSET_TABLE_
+ [BITS 64]
+ [GLOBAL lrotate:function] ; [1]
+ [GLOBAL greet:function] ; [1]
+ [GLOBAL asmstr:data asmstr.end-asmstr] ; [2]
+ [GLOBAL textptr:data 4] ; [2]
+ [GLOBAL selfptr:data 4] ; [2]
+ [GLOBAL integer:data 4] ; [3]
+ [EXTERN printf] ; [10]
+ [COMMON commvar 4:4] ; [7]
+ [EXTERN _GLOBAL_OFFSET_TABLE_]
- SECTION .text
+ [SECTION .text]
; prototype: long lrotate(long x, int num);
lrotate: ; [1]
pop rbx
ret
- SECTION .data
+ [SECTION .data]
; a string
asmstr db 'hello, world', 0 ; [2]
textptr dd greet wrt ..sym ; [15]
selfptr dd selfptr wrt ..sym ; [16]
- SECTION .bss
+ [SECTION .bss]
; an integer
integer resd 1 ; [3]
[section .text]
-global ghidden:hidden
-global ginternal:internal
-global gprotected:protected
-global gtoomany:hidden internal
+[global ghidden:hidden]
+[global ginternal:internal]
+[global gprotected:protected]
+[global gtoomany:hidden internal]
ghidden:
ginternal: