Page 1 of 1

A bit of help please

Posted: Fri Feb 06, 2004 7:29 am
by KieranFoot
Hi can anybody tell me weather this code will work, i'm asking because i'm in college and cant test it on their computers!!!

I'ts supposed to store the printers status value on the end of the string "PRN:".

Code: Select all

[org 0x0000]
[bits 16]

[SEGMENT .text]

mov ax, 0x0000                          
mov ds, ax     ;Initialize data segment
    
cli
mov ss, ax                           
mov sp, 0xFFFF ;Initialize stack                         
sti

mov ah, 0x00
mov al, 0x00
int 0x10       ;Set screen mode 0

mov ah, 0x05
mov al, 0x02
int 10h        ;Set active video page to 2

mov ah, 0x01
mov dx, 0x00
int 0x17       ;Initialize printer on LPT1
mov si, PrinterStatus
mov al, ah
stosb 

[SEGMENT .data]
PrinterStatus???db "PRN:", 0x00
I also have a mocro to print strings but where do i put it? :P ::)

A bit of a simple queston, but i havn't even tried to used these new fangled macro's yet ;D

Re:A bit of help please

Posted: Fri Feb 06, 2004 9:33 am
by Pype.Clicker
KieranFoot wrote: Hi can anybody tell me weather this code will work
it will work sunshiny days ... oops! you mean 'whether' ::) sorry.
I'ts supposed to store the printers status value on the end of the string "PRN:".
well, imho, it will not work as expected. First because you're using "si" with "stosb" while the 'destination' is in to be held in register "di" for that operation (don't have the Holly Manual here, but i'm rather sure of this)

Second, at PrinterStatus, you have the "P" character, so you're overwriting the first character instead of appending ...

Finally, i don't know what you have so interresting on video page 2, but i fear you'll simply don't see what you'll be printing with BIOS ...

Re:A bit of help please

Posted: Sat Feb 07, 2004 12:26 pm
by Schol-R-LEA
KieranFoot wrote: A bit of a simple queston, but i havn't even tried to used these new fangled macro's yet ;D
Macros usually are defined at the beginning of the code, before any code that applies them; they are often kept in separate includable header file, like C macros.

Keep in mind that, unlike subroutines, macros do not add an generated code in the part of the code where they are declared; rather, they define a template which is inserted into the code where the macro is applied, substituting the macro's formal parameters with the text of the applied arguments. For example (in NASM):

Code: Select all

%macro write 1
   mov si, %1
   call printstr
%endmacro

;...

   write testnumber   
   mov [bootdrv], dl   ; save boot drive info for later use
   write reset 
generates code like this:

Code: Select all

   mov si, testnumber 
   call printstr 
   mov [bootdrv], dl   ; save boot drive info for later use
   mov si, reset
   call printstr
You can also use C style macros, using %define (note that it uses the percent, not the hash, to mark definitions).

Code: Select all

%define zero(x) xor x, x

;...

   zero(ax)    ; clears the AX register
Refer to the NASM Manual for more details. HTH.