Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problems with Art of assemble code

bogdanul2003bogdanul2003 Member Posts: 153
I tried to assemble the shell.asm code from chapter four.It looks like this:
.xlist
include stdlib.a
includelib stdlib.lib
.list
dseg segment para public data
; Global variables go here:
dseg ends
cseg segment para public code
assume cs:cseg, ds:dseg
; Variables that wind up being used by the standard library routines.
; The MemInit routine uses PSP and zzzzzzseg labels. They must be
; present if you intend to use getenv, MemInit, malloc, and free.
public PSP
PSP dw ?
;--------------------------------------------
; Here is a good place to put other routines:
;-----------------------------------------------------------------
; Main is the main program. Program execution always begins here.
Main proc
mov cs:PSP, es ;Save pgm seg prefix
mov ax, seg dseg ;Set up the segment
registers
mov ds, ax
mov es, ax
mov dx, 0
meminit
jnc GoodMemInit
print
db Error initializing memory
manager,cr,lf,0
jmp Quit
GoodMemInit:
;***************************************************************************
; Put your main program here.
;***************************************************************************
Quit: ExitPgm
Main endp
cseg ends
; Allocate a reasonable amount of space for the stack (2k).
sseg segment para stack stack
stk db 256 dup (stack )
sseg ends
; zzzzzzseg must be the last segment that gets loaded into memory!
zzzzzzseg segment para public zzzzzz
LastBytes db 16 dup (?)
zzzzzzseg ends
end Main




But when i try to assembel it in masm32 or masm611(ML /Zi shell.asm) it says "cannot open file stdlib.a".
What's wrong ?

Comments

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : I tried to assemble the shell.asm code from chapter four.It looks like this:
    : .xlist
    : [red]include stdlib.a ;--- Can't find it! Find it in your code samples[/red]
    : includelib stdlib.lib
    : .list
    : dseg segment para public data
    : ; Global variables go here:
    : dseg ends
    : cseg segment para public code
    : assume cs:cseg, ds:dseg
    : ; Variables that wind up being used by the standard library routines.
    : ; The MemInit routine uses PSP and zzzzzzseg labels. They must be
    : ; present if you intend to use getenv, MemInit, malloc, and free.
    : public PSP
    : PSP dw ?
    : ;--------------------------------------------
    : ; Here is a good place to put other routines:
    : ;-----------------------------------------------------------------
    : ; Main is the main program. Program execution always begins here.
    : Main proc
    : mov cs:PSP, es ;Save pgm seg prefix
    : mov ax, seg dseg ;Set up the segment
    : registers
    : mov ds, ax
    : mov es, ax
    : mov dx, 0
    : meminit
    : jnc GoodMemInit
    : print
    : db Error initializing memory
    : manager,cr,lf,0
    : jmp Quit
    : GoodMemInit:
    : ;***************************************************************************
    : ; Put your main program here.
    : ;***************************************************************************
    : Quit: ExitPgm
    : Main endp
    : cseg ends
    : ; Allocate a reasonable amount of space for the stack (2k).
    : sseg segment para stack stack
    : stk db 256 dup (stack )
    : sseg ends
    : ; zzzzzzseg must be the last segment that gets loaded into memory!
    : zzzzzzseg segment para public zzzzzz
    : LastBytes db 16 dup (?)
    : zzzzzzseg ends
    : end Main
    :
    :
    :
    :
    : But when i try to assembel it in masm32 or masm611(ML /Zi shell.asm) it says "cannot open file stdlib.a".
    : What's wrong ?
    :

  • bogdanul2003bogdanul2003 Member Posts: 153
    [b][red]This message was edited by bogdanul2003 at 2004-8-14 6:20:33[/red][/b][hr]
    Now i'm trying to write the procedure for PutScreen from chapter 5 of Art of assembling.But when i run the appl instead of printing colored dots it prints black ones.I have made o modification in the main program as well switching ax with dx before the PutScreen call.Here is the code.If someone knows what's wrong pls tell me.

    .386
    option segment:use16

    .xlist
    include masm611includestdlib.a
    includelib masm611libstdlib.lib
    .list



    ; Ignore all the stuff between the following two lines containing asterisks
    ;
    ;****************************************************************************
    ;
    ; For Loop Support macros (See Chapter Seven for a description of how
    ; these macros work).



    ForLp macro LCV, start, stop ;LCV="Loop Ctrl Var"
    local ForLoop

    ifndef $$For&LCV&
    $$For&LCV& = 0
    else
    $$For&LCV& = $$For&LCV& + 1
    endif

    ;; Emit the instructions to initialize the loop control variable.

    mov ax, Start
    mov LCV, ax

    ;; Output Loop Label:

    ForLoop catstr <$$For&LCV&>, %$$For&LCV&
    &ForLoop&:

    ;; Output test to see if the loop is done:

    mov ax, LCV
    cmp ax, Stop
    jg @catstr(<;$$Next&LCV&>, %$$For&LCV&)
    endm




    ; Here is the NEXT macro:


    Next macro LCV
    local ForDone

    inc LCV
    jmp @catstr(<;$$For&LCV&>, %$$For&LCV&)
    ForDone catstr <$$Next&LCV&>, %$$For&LCV&
    &ForDone&:
    endm

    ;****************************************************************************
    ; Okay, here's where your stuff goes:


    dseg segment para public 'data'

    ; Insert declarations for the 16-bit integer variables I and J here.
    I word ?
    J word ?
    dseg ends
    cseg segment para public 'code'
    assume cs:cseg, ds:dseg
    ; Here's the procedure you need to modify. On entry, AX contains a word
    ; to write to display[i,j]. Compute this index in BX and write the value
    ; in AX to location ES:[bx] (the base address is es:0). Note: the display
    ; array is defined as follows DISPLAY: array [0..24, 0..79] of word. The
    ; I and J variables are both words.

    PutScreen proc
    push es
    mov bx, 0b800h ;Change to 0b000h for mono displays.
    mov es, bx


    ; Put your code that stores AX at location display[i,j] here.
    ; Remember, the base address of array display is es:0.
    ;
    ; Be sure to use row major ordering.
    [/b]mov ax,I
    [/b]mov bx,80
    [/b]mul bx
    [/b]add ax,J
    [/b]add ax,ax
    [/b]mov bx,ax
    [/b]mov es:[bx],dx

    ; End of your code.
    ;
    pop es
    ret
    PutScreen endp
    ; This is the main program that calls the procedure above (that you should
    ; have modified). You shouldn't need to modify this code at all.

    Main proc
    mov ax, dseg
    mov ds, ax
    mov es, ax
    meminit


    forlp j,0,79
    forlp i,0,24

    mov dx, 500h+"." ;Colored periods
    call putscreen

    next i
    next j

    getc ;Pause by reading the keyboard.

    forlp j,0,79
    forlp i,0,24

    mov dx, 1000h+" " ;Blue spaces.
    call Putscreen

    next i
    next j


    Quit: ExitPgm ;DOS macro to quit program.
    Main endp

    cseg ends

    sseg segment para stack 'stack'
    stk byte 1024 dup ("stack ")
    sseg ends

    zzzzzzseg segment para public 'zzzzzz'
    LastBytes byte 16 dup (?)
    zzzzzzseg ends
    end Main



Sign In or Register to comment.