flat assembler
Message board for the users of flat assembler.
Index
> Main > HOW to read a byte from a string |
Author |
|
inskipp 17 Mar 2004, 21:28
A 1 byte string is actually a word, which hi-byte is 0. So you can simply convert a byte to a string using movzx instruction and storing it somewhere in memory. Maybe this code will be helpfull:
Code: .data buffer rb 0xA000 temp_buffer dw ? .code (...) mov esi,buffer ;esi=pointer to first byte in a buffer output_1byte: movzx ax,byte[esi] ;extend the byte to word test ax,ax ;end of string? jz end_of_string mov [temp_buffer],ax ;store word invoke MessageBox,0,temp_buffer,0,0 inc esi jmp output_1byte end_of_string: ;done (...) |
|||
17 Mar 2004, 21:28 |
|
0x004549554F4C 17 Mar 2004, 23:43
.data
buffer rb 0xA000 buffer2 rb 20 cntr rd 1 .code invoke SendMessage,[edithwnd],WM_GETTEXT,0xA000,buffer mov eax, 00000000000000000000000000000000b mov ebx, 00000000000000000000000000000000b mov [cntr], 00000000000000000000000000000000b lbl1: mov ebx, [cntr] mov al, byte [buffer + ebx] cmp al, 0 je lbl2 cinvoke wsprintf, buffer2, fwsp, eax invoke MessageBox,[hwnd], buffer2,_about_title,MB_OK inc [cntr] jmp lbl1 lbl2: jmp finish thats how i solved my own problem, inskipps way is obviously much more efficient. thank you for you help |
|||
17 Mar 2004, 23:43 |
|
Bitdog 18 Mar 2004, 06:27
ZZTOP:
LODSB OR AL,AL ;if nul=0 JZ BYE ;X-it STOSB JMP ZZTOP ;short jmp BYE: ------------------------------------ Hello, at start up, [DS:SI] = source (of string, and) [ES:DI] = destination = screen address ? Things don't need to be any more complicated than you want them to be. KISS = Keep It Simple Stupid is my motto......'er, the motto I strive for... |
|||
18 Mar 2004, 06:27 |
|
VitalOne 20 Mar 2004, 00:36
Haven't tested it but...
Code: .data buffer rb 0xA000 buffer2 db 0,0 .code mov esi,buffer one_byte: lodsb mov byte[buffer2],al invoke MessageBox,NULL,buffer2,buffer2,MB_OK loop one_byte invoke ExitProcess,0 |
|||
20 Mar 2004, 00:36 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.