Hi to all:
My English is poor. But I try.
Some person can revise this program.
It will create a file.
It would have to show me 888 within the file.
But it shows me 888$$$$$
I did it, taking answers from others post.
;===========================
;;;;;ML /c convstri.asm
;;;;;DosLnk /tiny convstri.obj,convstri.com;
.model tiny
.386 ;Sin esto el push da error.
.data
FILE1 DB 'Addr.TXT',0 ;Nombre del Archivo.
Direci DW 00 ;Identificador de Archivo para DATA.
buff db 8 dup (24h )
.code
org 100h
Main:
push 40h
pop es
mov bx, 8
mov ax, es:[bx]
mov Direci,ax ;Guarda la Direccion del Pto.
;===============
mov ax, Direci
; mov dx, offset buff
lea dx, buff
call intToString
call printString
;===============
;Para guardar en el archivo Addr.txt
mov AH,3Ch ;Función de creación de archivos
lea DX, FILE1
xor CX,CX ;CX = 0
int 21h ;Accede al DOS
mov BX,AX ;Identificador para BX
;===============
mov AH,40h ;Escribe BUF al Final del archivo
mov CX, 10
lea DX, buff ;
;mov DX, offset buff
int 21h
mov AH,3Eh ;Función de cerrado del Archivo.
int 21h ;Accede al DOS
;Termina Programa
mov ax, 4C00h ;Terminate program execution
int 21h
;================
;Imprime la Cadena.
printString:
mov ax, 0900h ;Print String
int 21h
ret ;Retorna arriba
;Dentrro de la Cadena
intToString:
mov si, dx ;Mueve DX a SI (Source Index)
mov cx, sp ;Mueve SP (Stack Pointer) a CX
stiLoop:
xor dx, dx ;Pone en cero a DX
mov bx, 10d ;Carga BX con 10 decimal.
div bx ;Divide BX/DX me imagino.
add dl, '0' ;Suma 0 en DL
push dx
cmp ax, 01h ;Compara si AX = 1
jl reversing
jmp stiLoop ;Salta a stiLoop (Arriba)
reversing:
mov dx, si ;Mueve SI a DX
popLoop:
cmp cx, sp ;Compara CX con SP
je popdone
pop ax ;
mov byte ptr[si], al ;<== added 'ptr' here
inc si
jmp popLoop ;Salta a popLoop
popdone:
ret ;Retorna al call (Arriba)
end Main
;=============================================
Thank.
By(t)e ('_').
You are loading the value 10 into CX so the function is writing 10 bytes to the file.
mov AH,40h ;Escribe BUF al Final del archivo
mov CX, 10 ; <===
lea DX, buff ;
;mov DX, offset buff
int 21h
The string returned by intToString can be 1 to 5 characters. When you display the string or write it to a file you need to know how many characters it contains. The common method of doing this is to use a 0 (zero) byte to mark the end of the string. For example, the string '888' would be stored in memory as:
db '8','8','8',0
A good way to do this would be to change the code in intToString to add a 0 byte to mark the end of the string:
popdone:
mov byte ptr[si],0 ; <===
ret ;Retorna al call (Arriba)
And use a simple string length procedure to load the length of the string into CX before the interrupt call that writes to the file, something like this:
; Load offset address of string buffer into SI before call
strlen:
xor cx, cx ; initialize length to zero
@@:
cmp BYTE PTR [si], 0 ; compare bytes until find null
je @F
inc cx ; increment length
inc si ; increment address
jmp @B
@@:
ret
To display the string you could use the same function that you are using to write to the file, but instead of a file handle in BX you would specify the standard output handle (1).
Just a side note: a comment has striked me:
> SI (Stack Index)
the S from 'SI' does not come from S)tack, it comes from S)ource (and the D from 'DI' from D)estination). This is because these two registers are somewhat destined to be used as pointers for reading/moving/storing blocks of data.
Hi to all:
My English is poor. But I try.
Gustav:
You are right.
I have made an error. It is corrected.
Please understand me.
Reading here, reading there, searching in 4 books, searching in other forums.
My head stops. And I make errors.
I gave a kick to the Assembly language
Please accept my apologies. Whole-heartedly.
Pardon me. I am ashamed.
A week of tests and rehearsals. When my brain stops. I request help here. :wink
MichaelW:
I see that you collaborate with all. God blesses to you.
I don't know how I'll be able to make it up to you.
Quote from: MichaelW on February 26, 2006, 01:23:42 AM
you would specify the standard output handle (1).
I think that it is 2. Am I mistaken?
I sometimes think that my lamp is failing. My lamp needs more oil, or new battery. ( I am joking. )
Code:
call strlen ;<==================>Here. It opens the empty file.
mov AH,40h ;Escribe BUF al Final del archivo
mov CX, 10
lea DX, buff ;
;mov DX, offset buff
call strlen ;<==================>Here. It opens the empty file.
int 21h
Without the procedure (strlen) it writes in file (888 $$$$). It is better.
If change (mov CX, 10) by (mov CX, 4) it works. But the procedure strlen does not work to me.
[/size]
Thanks.
By(t)e ('_').
For DOS, the standard (device) handles are:
STDIN = 0
STDOUT = 1
STDERR = 2
STDAUX = 3
STDPRN = 4
For Interrupt 21h function 40h, CX should contain the number of bytes to write to the file (or standard output device). Offset 8 in the BIOS data area contains the base address of the first parallel port, typically 378h = 888 (3 digits). If instead you were reading offset 0, the base address of the first serial port, the value would typically be 3F8h = 1016 (4 digits). If you made the changes I suggested, the intToStr code would add a zero byte to the end of the converted value, and you could use the strlen code to load the length into CX, and your program would work for any string that would fit in the buffer.
Hi to all:
My English is poor. But I try.
Please Mr. MichaelW reads the other post. I modified it by power cut.
Quote from: MichaelW
Posted on: Today at 09:54:24 AM
For DOS, the standard (device) handles are:
STDIN = 0
STDOUT = 1
STDERR = 2
STDAUX = 3
STDPRN = 4
I was confused.
I thought that 02h for int 21. Pardon.[/size]
Thank.
By(t)e ('_').
; Load offset address of string buffer into SI before call <=====
; Returns with length in CX
strlen:
xor cx, cx ; initialize length to zero
@@:
cmp BYTE PTR [si], 0 ; compare bytes until find null
je @F
inc cx ; increment length
inc si ; increment address
jmp @B
@@:
ret
mov ah,40h ;Escribe BUF al Final del archivo
mov si, offset buff ;<=====
call strlen
mov dx, offset buff
int 21h
This is how you could use the Write File or Device function to display a zero-terminated string:
STDOUT EQU 1
printString:
mov ah, 40h
mov bx, STDOUT
mov si, offset buff
call strlen
mov dx, offset buff
int 21h
ret
Also, 'byte ptr' not needed here because MASM knows the size of the memory operand from the size of the register operand:
mov byte ptr[si], al
But 'byte ptr' is needed here because MASM has no other way to know the size of the memory operand:
mov byte ptr[si],0
Hi to all: My English is poor. But I try.
Mr. MichaelW
It worked !!
I was mistaken. You are not my lamp.
Let me to extol you.
You are a powerful lamp. You don't need more oil. (I need to study more.)
You are the center of the energy. You are 3 Brains. You are the Albert Einstein of the Assembly language.
You are DEXTER'S Lab. You are Jimmy neutron. You are the MASTER of the Assembly language.
You are a: Power, Wonderful, Gentlemen, Father, Star, Atomic, Gold, etc.
I am tired.
I make many flatteries. But it is this way like I can pay.
Here I place the program in a file .zip
With a good help from MichaelW. (The Master¡¡)
Thanks Whole-heartedly.
By(t)e ('_').
[attachment deleted by admin]
Quote from: IAO on March 01, 2006, 07:00:40 PM
Hi to all: My English is poor. But I try.
Mr. MichaelW
It worked !!
I was mistaken. You are not my lamp.
Let me to extol you.
You are a powerful lamp. You don't need more oil. (I need to study more.)
You are the center of the energy. You are 3 Brains. You are the Albert Einstein of the Assembly language.
You are DEXTER'S Lab. You are Jimmy neutron. You are the MASTER of the Assembly language.
You are a: Power, Wonderful, Gentlemen, Father, Star, Atomic, Gold, etc.
I am tired.
I make many flatteries. But it is this way like I can pay.
Here I place the program in a file .zip
With a good help from MichaelW. (The Master¡¡)
Thanks Whole-heartedly.
By(t)e ('_').
Your program makes addr.ini with 956 in it. What exactly is it ?
Thanks.
I have a lot of .86 code if you would like it.
Let me know.
skywalker,
956 is the value 3BCh, in decimal. This was the base address of the parallel port that was implemented on the MDA/HGA adapters. Many of the I/O cards that provided parallel ports used, or could be configured to use, this address. On your system the address is probably a 'virtual' parallel port provided by Windows. On my Windows 2000 system I have two serial ports and one parallel port. If I run DEBUG from a boot diskette and dump the first 7 words of the BIOS data area (containing the base addresses of the first four serial ports and the first three parallel ports), I get 3F8h, 2F8h, 0, 0, 378h, 0, 0. If I do the same under Windows 2000, I get 3F8h, 2F8h, 3E8h, 2E8h, 3BCh, 378h, 278h.
Quote from: MichaelW on March 01, 2006, 11:31:29 PM
skywalker,
956 is the value 3BCh, in decimal. This was the base address of the parallel port that was implemented on the MDA/HGA adapters. Many of the I/O cards that provided parallel ports used, or could be configured to use, this address. On your system the address is probably a 'virtual' parallel port provided by Windows. On my Windows 2000 system I have two serial ports and one parallel port. If I run DEBUG from a boot diskette and dump the first 7 words of the BIOS data area (containing the base addresses of the first four serial ports and the first three parallel ports), I get 3F8h, 2F8h, 0, 0, 378h, 0, 0. If I do the same under Windows 2000, I get 3F8h, 2F8h, 3E8h, 2E8h, 3BCh, 378h, 278h.
Is HGA for Hercules ? And what is MDA.
Thanks for the info.
HGA is an acronym for Hercules Graphics Adapter. AFAIK MDA was the 'official' IBM acronym for Monochrome Display Adapter.
Hi to all: My English is poor. But I try.
Mr. skywalker
To explain to it is difficult for me in English, but I will try.
To make a Post it takes me from 1 TO 3 Hours.
I have a program in masm32 (LedAsmG5.Asm).
Please see here.
http://www.masmforum.com/simple/index.php?topic=3856.msg28734#msg28734
http://www.masmforum.com/simple/index.php?action=dlattach;topic=3856.0;id=2019
In Win98 it works well.
But in WinXP it doesn't work.
The program uses Inpout32.dll.
The file addr.ini takes a decimal value.
I will take this decimal value, and I will put it in an EDITBOX.
This way WinXP will show the decimal value. This is as a trick.
Mr. MichaelW told me of WINIO, but I think that it is more complicated.
To add another DLL is more complicated. And the program is very simple.
The program in Masm32 has been an enormous effort for my.
But I am happy. Soon I will finish it.
I make my programs so that others learn. I also learn.
If you don't understand something tells it to me. I write it again.
A lot of people don't understand me, when I write.
Mr. MichaelW explained it far better. He is right.
Kung-Fu:
Effort, Insistence and Dedication, for a perfect execution.
Fuerza, Insistencia y Dedicación, para una correcta ejecución.
Thanks.
By(t)e ('_').
Quote from: IAO on March 02, 2006, 12:59:10 PM
Hi to all: My English is poor. But I try.
Mr. skywalker
To explain to it is difficult for me in English, but I will try.
To make a Post it takes me from 1 TO 3 Hours.
I have a program in masm32 (LedAsmG5.Asm).
Please see here.
http://www.masmforum.com/simple/index.php?topic=3856.msg28734#msg28734
http://www.masmforum.com/simple/index.php?action=dlattach;topic=3856.0;id=2019
In Win98 it works well.
But in WinXP it doesn't work.
The program uses Inpout32.dll.
The file addr.ini takes a decimal value.
I will take this decimal value, and I will put it in an EDITBOX.
This way WinXP will show the decimal value. This is as a trick.
I was wondering what the decimal value is from and what you want to use it for.
I hope you understand me.
Good luck,
Andy
Hi to all:
My English is poor. But I try.
Mr. skywalker
I understand to you. The difficult thing for me is to write.
956 is the value 3BCh, in decimal. 888 is the value 378h, in decimal.
It is more easier to write it in the file (ADDR.ini) in a decimal value .
QuoteI modified this fact by MichaelW.
I am trying to access the BIOS data area and the base I/O address for one of the parallel ports.
I cannot do these things from a normal Windows program, even running under Windows 98.
To a normal Windows program the BIOS data area does not exist, and most or all of the I/O ports are protected.
Quote
and what you want to use it for.
I will get this decimal value contained in the file (Addr.ini). And I will put it in a EDITBOX.
___________<--------The program will show to the decimal value here.
| 956 |
|__________| <-------Is my EditBox in my program.
I hope you understand me.
I was occupied yesterday.
[/size]
Thanks for your patience.
Bye ('_').