flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
t jip mc 30 Jul 2005, 19:58
offset and ptr[] dont work?
|
|||
![]() |
|
Matrix 30 Jul 2005, 21:52
hi,
could you describe more clearly what do you want to do? Code: mov al,byte [_text] ; this puts byte 'h' into al mov ax,word [_text] ; this puts byte 'h' into al, 'i' into ah mov eax,dword [_text] ; this puts bytes 'hi i' into eax , h in al i in ah ... also lodsb, lodsw and lodsd works like this, read memory to register accumulator from [ds:si] or [esi] (in 32 bit mode) _text : db "hi i want the 1234 bytes of this db value" additionally you can translate offset like: Code: offset equ ;equ nothing mov si,offset _text ; this puts offset text into si (16 bit mode) ;also mov si,_text ; this puts offset text into si (16 bit mode) ;does the same |
|||
![]() |
|
T&K(r) 30 Jul 2005, 22:27
I don't think abaut this a lot, but i think that the simplest ( and the worst ) method is to do something like this
cmp [countervar], 0x04 jnp getabyte getabyte: mov bl,[text] dec [countevar] cmp [countevar],0 je end mov bl, [text+1] dec [cuntevar] cmp [countevar],0 je end mov bl, [text+2] dec [cuntevar] cmp [countevar],0 je end mov bl, [text+3] dec [cuntevar] cmp [countevar],0 je end mov bl, [text+4] dec [cuntevar] cmp [countevar],0 je end - and this about 1234 or more times - mov bl,[text+n] - you change only red text end: countevar dw ? text: DB "hi i want the 1234 bytes of this db value" This is the simplest example what i ever do ( but works ![]() ![]() _________________ my GG ( Polish Instant Messager ) number is 8734187 Gdy widzisz kolejke - wstąp do niej - co ci szkodzi ![]() |
|||
![]() |
|
T&K(r) 30 Jul 2005, 22:29
At beggining :
Quote:
should be Code: mov [countevar],4 jmp getabyte Sorry for bug _________________ my GG ( Polish Instant Messager ) number is 8734187 Gdy widzisz kolejke - wstąp do niej - co ci szkodzi ![]() |
|||
![]() |
|
t jip mc 30 Jul 2005, 23:10
thanks for the quick response, i have done it. It's a meag dummy question but from time to time easy code could be difficult.
however if i make a dword for counting and put it in a esi register all works fine like: county dd 0x0 inc [county] mov esi,[county] mov bl,byte[text+esi] but why i can't use other register the compiler told reserved and defined as symbol or is shutdown instead of compiling. thanks a lot |
|||
![]() |
|
Matrix 31 Jul 2005, 14:58
hmm
, i'd suggest you reading a few codes in DOS for example, like string writing to screen, so you are gonna output bytes in serial port? Code: org 256 push ds push cs pop ds call init_serial mov si,msg1 call serial_writestr pop ds int 20h ; Standard Address - Port ; $3F8 = COM1 ; $2F8 = COM2 ; $3E8 = COM3 ; $2E8 = COM4 ; Divisor - Baud Rate ; $01 = 115200 ; $02 = 57600 ; $03 = 38400 ; $06 = 19200 ; $0C = 9600 ; $18 = 4800 ; $30 = 2400 base=$3f8 ; COM1 baud=$03 ; 38400 baud serial_writestr: ; input: ds:si = string address (null terminated string) .loop: lodsb or al,al jz .done call write_serial jmp .loop .done:ret init_serial: mov dx,base+1 ; interrupts off xor al,al out dx,al mov al,$80 ; DLAB on mov dx,base+3 out dx,al mov dx,base ; Set baud rate mov al,baud ; baud rate (38,400 is default) out dx,al mov dx,base+1 ; Set baud rate xor al,al out dx,al mov dx,base+3 ; 8 bits, no parity, 1 stop bit mov al,$03 out dx,al mov dx,base+4 ; Turn on DTR, RTS, and OUT2 mov al,$0b out dx,al mov dx,base+2 ; Enable FIFO mov al,$c7 out dx,al ret read_serial: ; returns: al=byte read from serial mov dx,base+5 ; LSR .wait: in al,dx test al,1 jz .wait mov dx,base in al,dx ret write_serial: ; al=byte to send mov dx,base+5 ; LSR xchg ah,al .wait:in al,dx test al,$20 ; Bit 5 of LSR is set when transmit buffer is empty jz .wait xchg ah,al mov dx,base out dx,al ret msg1: db 'I am the string to be outputted to serail port',0 ; null terminated string |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.