NASM Forum > Using NASM
Linux or DOS
fredericopissarra:
--- Quote from: Frank Kotler on November 18, 2020, 09:44:50 PM ---Untested! I think that's right. Holler if any problem or if you want to make a '.com' file out of it (model tiny).
--- End quote ---
Small changes made by me:
--- Code: ---; PROGRAM.ASM
;
; Compile:
; nasm -f obj program.asm
;
; link program.obj (using Borland C++ 3.1 or Turbo C 2.1 linker)
; tlink /n program.obj,program.exe
;
; OBS: DOS don't use '.section' names. The sectios are:
; 'stack', 'code' and 'data' (and 'bss' if it exists).
;
; OBS: I don't think Visual Studio's LINK can handle DOS
; executables anymore.
;
; OBS: If you want to make sure to use only 8086 instructions,
; you can use 'cpu 8086', otherwise 386 instructions will be
; available to you in real mode.
bits 16
;cpu 8086 ; uncomment to make sure 8086 instructions only.
; -------- STACK for the EXE process.
section stack stack ; first "stack" is name,second is attribute
resb 256 ; 256 bytes stack (is enough for this small program).
stack_top equ $
; -------- OUR DATA segment
section data data
Asterisks1 db `*****\r\n$`
Asterisks2 db `* *\r\n$`
; -------- OUR CODE segment
section code code
..start:
; Need to setup stack!
mov ax,stack
mov ss,ax
mov ax,stack_top
mov sp,ax
mov ax,data
mov ds,ax
; print top row.
lea dx,[Asterisks1]
mov ah,9
int 0x21
; print 3 middle rows.
mov cx,3
.loop:
lea dx,[Asterisks2]
mov ah,9
int 0x21
dec cx
jnz .loop
; print bottom row.
lea dx,[Asterisks1]
mov ah,9
int 0x21
; exit(0)
mov ax,0x4c00
int 0x21
--- End code ---
Tested with NASM and TLINK (Borland C++ 3.1 or Turbo C 2.1) in DOSBOX.
NASM compilation on Linux... Linkage on DOSBOX.
Frank Kotler:
Thanks Debs
Thanks Frederico
Many eyes make fewer bugs!
Best,
Frank
Navigation
[0] Message Index
[*] Previous page
Go to full version