NASM Forum > Using NASM

Linux or DOS

(1/2) > >>

Azrael998:
Hello everyone, I have an assignment I need to create a program that displays a 5 by 5 asterisk on the screen using int 21H. My question is do I have to use DOS or can I use Linux?, does Linux have system call similar to DOS' int 21H?.

Frank Kotler:
Hi  Azrael998,

Int 21h is dos only. Linux could use sys_write to write one or more assesterisk on the screen. 5x5 might be a problem. What subfunction of Int 21h does the assignment use? Does this draw one big asterisk or a "box" or "block" of 'em? Your best bet might be to install Dosbox or some such, but maybe we can figure our how to do  it in Linux.
   |             *****
 \   /           *     *
-      -   or  *     *  or ?
  /   \          *     *
    |            *****

... this stuff looks poor... I'm thinkin' Dosbox...

Best,
Frank


Azrael998:
Hi Frank,

I installed DOS and assembled the code using MASM but my professor says that it should be assembled using NASM do you know how to convert the code to NASM?.

Here's the MASM code:
.model small
.stack 100h

.data
  Asterisks DB '*****',0DH,0AH,'$'

.code
  Main Proc
    mov ax, @data
    mov ds, ax
    mov cx, 5

    _loop1:
    mov ah, 9
    lea dx, Asterisks
    int 21H
    dec cx
    jnz _loop1

    mov ah, 4ch
    int 21h
  Main ENDP
END Main

This prints out:
*****
*****
*****
*****
*****

Frank Kotler:
Oh shift! I used to do this stuff all the time... a long time ago,

This shouldn't need to be "small"... but to try to make it the same...


--- Code: ---; nasm -f obj program.asm
; link program.obj ; ?

; nasm doesn't use "model"
;.model small

section stack stack ; first "stack" is name, second is attribute
resb 100h

section .data
  Asterisks DB '*****',0DH,0AH,'$'

section .code ; nasm knows ".text" but not for -f obj

..start  ; for -f obj only!

; Main Proc  ; not for nasm

    mov ax, .data
    mov ds, ax
    mov cx, 5

    _loop1:
    mov ah, 9
    lea dx, [Asterisks]  ; "lea" wants "[contents]"
    int 21H
    dec cx
    jnz _loop1
; or just 'loop loop1' decrements cx and jumps if non-zero

; exit cleanly
    mov ah, 4ch
    int 21h

;  Main ENDP ; not for nasm
;END Main ; not for nasm

--- End code ---

This prints out:
*****
*****
*****
*****
*****
Untested! I think that's right. Holler if any problem or if you want to make a '.com' file out of it (model tiny).

Code tags: put the word "code" in square brackets, "/code" it the end. Makes it easier to read? and easier to cut and paste!

Best,
Frank

debs3759:

--- 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 ---

Looks right to me (assuming the int 21h calls are right)

Navigation

[0] Message Index

[#] Next page

Go to full version