assembly question
assembly question
hi
if for example i m using int 62h/AX=0072h to get the size of video memory
it
Returns:
AX = size of video memory in KB
now how can i show this size of vidmem on the
screen..just like we display messages on the screen
thanx for ur help
if for example i m using int 62h/AX=0072h to get the size of video memory
it
Returns:
AX = size of video memory in KB
now how can i show this size of vidmem on the
screen..just like we display messages on the screen
thanx for ur help
Re:assembly question
Yes..but in hex(correct?)...you could use my C/C++ printf in pk0.7.1 ( new release ). ( actually...I got this printf from Chris's Triple Fault site )
Re:assembly question
well tom i m not talking about C .. i m talking about assembly .. i think i mentioned that too
can some one tell me how i can print the hex values in any registers on the screen
can some one tell me how i can print the hex values in any registers on the screen
Re:assembly question
This thread discusses a general algorithm for converting a binary to a string, for any number base.adeelmahmood1 wrote: well tom i m not talking about C .. i m talking about assembly .. i think i mentioned that too
can some one tell me how i can print the hex values in any registers on the screen
Re:assembly question
well actually i dont know .. i have checked that algorithm and i m still confused .. ok let me ask it this way
here is the code to print a msg on the screen
ok now if we have '1111000011110000' in and ax and i wanna print that on the screen .. wat should i do
can i do it like
mov si,ax
call print
BTW thanx for ur help
here is the code to print a msg on the screen
Code: Select all
mov si,msg
print:
lodsb
cmp al,0
je done
mov ah,0eh
mov bx,7
int 10h
jmp print
done:
mov ah,4ch
int 21h
msg db 'hello',13,10,0
can i do it like
mov si,ax
call print
BTW thanx for ur help
Re:assembly question
Here you go, I am feeling really generous .
This code works as follows:
You must push two parameters onto the stack, first push the number (eax), then push the address of a buffer to place the string in, then call the function, the parameters will be removed for you, if you want to make the function smaller you can remove the code marked as optional, all it does is remove any leading zeros from the number, for example if you passed the number 0x0003dbb4 it would put in the buffer 3dbb4.
Here is an example of its use, you could write a function that would display the contents of eax like this:
Hope this helps.
Code: Select all
_Num2HexStr:
PUSH EBP
PUSH EAX
PUSH EBX
PUSH ECX
PUSH ESI
MOV EBP, ESP
; === START OPTIONAL CODE ===
.Hexadecimal_Conversion:
MOV ESI, DWORD [EBP + 24]
MOV EBX, DWORD [EBP + 28]
CMP EBX, 0
JE .End_Hex_Conversion_Zero
MOV ECX, 8
.Remove_Lead_Zeros:
ROL EBX, 4
MOV AL, BL
AND BL, 0x0F
CMP BL, 0
MOV BL, AL
JE .Skip_Zero
JMP SHORT .Start_Conversion_Loop
.Skip_Zero:
DEC ECX
JMP SHORT .Remove_Lead_Zeros
.Start_Conversion_Loop:
ROR EBX, 4
; === END OPTIONAL CODE ===
.Conversion_Loop:
ROL EBX, 4
MOV AL, BL
AND AL, 0x0F
OR AL, 0x30
CMP AL, 0x39
JNA .Dont_Add_7
ADD AL, 0x07
.Dont_Add_7:
MOV BYTE [ESI], AL
INC ESI
DEC ECX
CMP ECX, 0
JE .End_Hex_Conversion
JMP SHORT .Conversion_Loop
.End_Hex_Conversion:
MOV BYTE [ESI], 0
JMP .End_Conversion
.End_Hex_Conversion_Zero:
MOV BYTE [ESI], '0'
MOV BYTE [ESI + 1], 0
.End_Conversion:
POP ESI
POP ECX
POP EBX
POP EAX
POP EBP
RET 8
You must push two parameters onto the stack, first push the number (eax), then push the address of a buffer to place the string in, then call the function, the parameters will be removed for you, if you want to make the function smaller you can remove the code marked as optional, all it does is remove any leading zeros from the number, for example if you passed the number 0x0003dbb4 it would put in the buffer 3dbb4.
Here is an example of its use, you could write a function that would display the contents of eax like this:
Code: Select all
buffer db 0,0,0,0,0,0,0,0,0 ; requires 9 bytes at the most
_Display_EAX:
push eax
push buffer
call _Num2HexStr
mov si, buffer
call print
ret
Re:assembly question
You are very welcome, also if you decided to leave the optional code in there, then you should recopy the code from above, because I was looking at the code again and I noticed a way to save 10+ bytes and 25+ clock cycles, so it was quite a big optimization, I edited the code in place so just recopy it and replace the old version with the new one above.
Re:assembly question
i dont know wats wrong coz it worked fine for the first time and now its giving an error on the line
error: operation size not specified
can u see wats going on :'(
Code: Select all
_Display_EAX:
push eax
push buffer ============>>> error
call _Num2HexStr
mov si, buffer
call print
ret
can u see wats going on :'(
Re:assembly question
This error means that nasm isn't sure of what size you are working with, just change
push buffer
to
push dword buffer
and all should go well.
push buffer
to
push dword buffer
and all should go well.