Help me Pls. I want to make this Program from 16 bits to 32 bits

Started by Peace, February 14, 2012, 04:11:54 PM

Previous topic - Next topic

Peace

I try to make this program to 32 bits but it's error when I assembling it.

jj2007

This is 16-bit code, so you need \Masm32\bin\link16.exe
Assembles. links and runs just fine under Win XP SP3.

Peace

Yeah. This is a 16 bits code but I want it in to 32 bits code (Convert this program this 16 bits to 32 bits). I can't do it.

jj2007

What is it, homework? Or something important that needs to be solved? Some people here are looking for a job, actually (not me).

This does roughly what your code does, in 32-bit assembly:

include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init
   .Repeat
      Inkey "Your input was [", Input$("Please enter a string, max 80 chars: "), "]", CrLf$, "One more (y)?", CrLf$
   .Until eax!="y"
   Exit
end start

MichaelW

If you intend to use the MASM32 macros and procedures for the 32-bit code, it will be very different from the 16-bit code and much smaller. Instead of doing a conversion where you would have to change or discard ~90% of the code, I think it would be better to just create a 32-bit version that produces the same results. For an example to use as a starting point try masm32\examples\exampl02\textio\textio.asm.
eschew obfuscation

Peace

It's a homework. I think it very hard to me to make that from 16 bit to 32 bit. I try to make it 6 days but it's not successfully. Thank you very much jj 2007  :U. (Sorry I'm not so strong in English. I'am Thai)  :bg

jj2007

Good luck, Peace. There is a 'no homework rule' here, but sometimes we are tolerant :bg

Just in case your teacher gets a heart attack when he sees...
Inkey "Your input was [", Input$("Please enter a string, max 80 chars: "), "]", CrLf$, "One more (y)?", CrLf$
...:
- Bring a bottle of cognac, and give him a glass of it, immediately. It may save his life.
- Tell him that it's assembler because the code assembles just fine with standard Microsoft assemblers (i.e. Masm)
- Tell him that it's just a library, and that...
.data
mytext db "What an overkill", 13, 10, 0
.code
invoke StdOut, offset mytext
....
StdOut proc lpszText:DWORD
    LOCAL hOutPut  :DWORD
    LOCAL bWritten :DWORD
    LOCAL sl       :DWORD
    invoke GetStdHandle,STD_OUTPUT_HANDLE
    mov hOutPut, eax
    invoke StrLen,lpszText
    mov sl, eax
    invoke WriteFile,hOutPut,lpszText,sl,ADDR bWritten,NULL
    mov eax, bWritten
    ret
StdOut endp

  ... looks much more professional but does the same as PrintLine "What an overkill" and still uses two libraries (WriteFile, StrLen) :bg

@Hutch:
\Masm32\examples\exampl02\textio\textio.asm
__UNICODE__=1
      include \masm32\include\windows.inc
No success :(

Peace


dedndave

i am not so sure that the program does what it was intended to do
5 line buffers are created, but only the first one is actually used for keyboard input
ask your instructor if he wants you to debug his code before or after you convert it to 32-bit   :P
you may want to give him the whole bottle of cognac, first

if you want some help, tell use exactly what the resulting 32-bit program is supposed to do  :U

hutch--

JJ,

Quote
@Hutch:
\Masm32\examples\exampl02\textio\textio.asm

Look at the example and you will see that its ANSI only code. DB sized data in both DATA section and the LOCAL InputBuffer. It is a very old example left there for continuity.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Hutch,

The new version might profit from a thread showing how ANSI and UNICODE versions can be handled. Console I/O is not the best example, of course - extremely tricky. But a simple window that differs only in the Unicode switch would be cool.

For the console fans, attached a "work in progress" version using wInput$(). It does miracles but you need the fonts installed, of course.

include \masm32\MasmBasic\MasmBasic.inc   ; attached

  Init

  .While 1
   Locate(0, 3)
   wInkey "English, Arabic, Russian, Chinese or Thai (Escape=Exit) ? "
   .Break .if eax==VK_ESCAPE
   or eax, 32
   .if Instr_("eract", Chr$(eax))
      dec edx
      lea eax, [edx*4+5]  ; Instr returns edx=1, 2, ..
      imul ecx, edx, 400  ; the wRes$() strings are 1, 2, 3, 4 ... 401, 402, 403, 404, ... 801, 802 etc
      Locate(0, eax)  ; a different position for every language
      ConsoleColor cYellow
      wLet esi=wInput$(wRes$(ecx+1))
      wLet esi=esi+wCrLf$+wInput$(wRes$(ecx+2))
      wLet esi=esi+wCrLf$+wInput$(wRes$(ecx+3), wRes$(ecx+4))
      ConsoleColor cGray
      Locate(0, 30)
      wPrint esi, wChr$("       ")
   .endif
  .Endw
  Locate(0, 35)

  Exit

end start

English, Arabic, Russian, Chinese or Thai (Escape=Exit) ?

Введите ваше имя:       jj
Введите фамилию:        2007
Введите ваш доход:      1,000 Евро / год