Author Topic: Deficient value assessment from standard read and write call functions  (Read 11768 times)

Offline Deskman243

  • Jr. Member
  • *
  • Posts: 49
Greetings everyone
 I am moving from my most recent post to discuss a new block in the standard library code. There is an apparent deficiency in regards to the afore mentioned read and write calls. Here I have a simple boot and two different instances (from distinct sources) both not yielding any effect.


Code: [Select]
section .data
;    pathname dd "/home/Documents/Platforms/Programs/Sources/referenceA2023/Concepts/Codec/DesignII/Test/Base/new.text"

;    pathname dd "/home/chris-deb-auth/Documents/Platforms/Programs/Sources/A2024/small_rebuild/new.txt"
;    toWrite dd "test text here",0AH,0DH,"$"
;   length equ $ - toWrite

    filename db "new.txt", 0 ; filename with null terminator
    toWrite dd "test text here",10
 ;   message db "Hello, world!", 10 ; message with newline
 ;   msglen equ $ - message ; length of message
   length equ $ - toWrite


section .text

global Filer

Filer:
    ; open the file
    mov eax, 2 ; sys_open
;    mov ebx, pathname ; pointer to filename
    mov ebx, filename ; pointer to filename
    mov ecx, 0x201 ; O_WRONLY|O_CREAT
    mov edx, 0x1b6 ; 0644
    int 0x80 ; call kernel
    mov esi, eax ; save file descriptor

    ; write to the file
    mov eax, 4 ; sys_write
    mov ebx, esi ; file descriptor
    mov ecx, toWrite ; pointer to message
    mov edx, length ; length of message
    int 0x80 ; call kernel

    ; close the file
    mov eax, 6 ; sys_close
    mov ebx, esi ; file descriptor
    int 0x80 ; call kernel

    ; exit the program
    mov eax, 1 ; sys_exit
    mov ebx, 0 ; exit code
    int 0x80 ; call kernel


jmp $


times 510 - ($-($$)) db 0
db 0x55,0xaa


Code: [Select]
section .data
;    pathname dd "~/.../new.text"

   pathname dd "new.txt"
   toWrite dd "test text here",0AH,0DH,"$"
   length equ $ - toWrite



section .text

global Filer

Filer:
;section .data
;    pathname dd "/home/Documents/Platforms/Programs/Sources/referenceA2023/Concepts/Codec/DesignII/Test/Base/new.text"
;    toWrite dd "test text here",0AH,0DH,"$"
 

    mov eax,5
    mov ebx,pathname
    mov ecx,101o
    mov edx,700o
    int 80h

    mov ebx,eax
    mov eax,4
    mov ecx,toWrite
    mov edx,17

;    mov edx,length
    int 80h


jmp $


times 510 - ($-($$)) db 0
db 0x55,0xaa


I''m trying to understand each of these instances but if I can't get a yield I really don't have any clue. If anyone else has been through this library I could really use whatever can get through this.

Cheers and Regards
« Last Edit: January 14, 2024, 08:14:37 PM by Deskman243 »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Deficient value assessment from standard read and write call functions
« Reply #1 on: January 15, 2024, 12:28:21 AM »
  ; open the file
    mov eax, 2 ; sys_open

My menory' s all  shot. Is this right?

2 fork 5 open ?

Best,
Frank


Offline Deskman243

  • Jr. Member
  • *
  • Posts: 49
Re: Deficient value assessment from standard read and write call functions
« Reply #2 on: January 20, 2024, 02:52:10 AM »
They were both two different sources of the same port library. The first was creating input for a file and the second was for reading output to a file. Could you figure it out or did you need something else?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Deficient value assessment from standard read and write call functions
« Reply #3 on: January 20, 2024, 08:04:05 AM »
I may have missed 32 vs 64 bit sytm calls...

Best,
Ftank