flat assembler
Message board for the users of flat assembler.
Index
> Main > [RU] Help with converting MASM -> FASM |
Author |
|
sid123 09 Apr 2014, 12:30
What's goin' on the forums, just because i only know english and use "Google Translate" LOL. doesn't mean people come around like this.......
Anyways, hi MIHIP, I recommend to use English wherever possible, since a lot of people may not be knowing your language, I used Google Translate and here's what I came up with: Google Translate wrote:
I guess what you want is translating the TASM code to FASM? I can't really understand the first 3 lines of translation, (1/∞ reasons not to trust Google Translate when you go outside the country.) And now for the code (I'll break it part by part) Add this (for COM) Code:
org 0x100
Code: .model small Not needed, cut off. Code: .186 Why bother using 80186, it was crap, so why not use 386+ Instructions when we've got awesome stuff in 2014? Cut off. Code:
.stack 100h
I'm not sure about this but this should set the stack to 0x100 (which seems to be a "little" sane as a DOS program starts a 0x100, and the stack grows down, so yeah you can simply add this line of code somewhere in your code initialization: Code: ...... ;; Grab CS. mov ax, cs ;; idk, but the CPU should clear interrupts while shifting stack cli ;; Set Stack Segment to current code segment mov ss, ax ;; set sp to 0x100 mov sp, 0x100 ;; Restore IF to normal sti ..... I don't recommend setting the stack to 0x100, as it's just 256-bytes and you'll have a stack overflow quick, (128 word pushes or 64 dword should be enough to bring it to 0xFFFF) Instead set the Stack Segment to 0x9000 and set stack pointer to 0, (to make it aligned), that's after a potential EBDA territory so you should be safe. Code: .data ;5A7C5F6 mass db 0f6h,0c5h,0a7h,05h ;128 dup(33h); msg db "bez osta4i$" r dw 4 Not need, cut off .data, and shift the code to somewhere below in source code (you shouldn't be executing the data section....) Code: .code Cut off. Code: start: mov ax,@data mov ds,ax Um, I have no idea what is equivalent to this in FASM, basically it seems to be giving the data segment to the data section, since we're COM, so DS=CS, no need. cut off or if you really want to be awesome: Code: ;; awesomenessssss. ;; set DS=CS mov ax, cs mov ds, ax Code: ;<5B>4 >B=8<0=8O ;?5@59B8 2 :>=5F 8 =0G0BL >B BC40 mov bx,15 ;G8A;> =0 :>B>@>5 45;8< mov si, offset mass No idea what those comments mean, but remove the "offset", since it's crap MASMery. Code: add si,3 std xor ax,ax LODSB mov cx,[r];@07<5@ <0A820 2 109BE aaa1: cmp ax,bx jb m1;<5=LH5 div bl jmp n2 m1: mov ah,al n2: LODSB loop aaa1 cmp ah,0 jne mexit mov ah,9 lea dx,msg int 21h mexit: mov ax,4c00h int 21h Replace mov cx, r with mov cx, [r] as pointed out by revolution. Code: end start No need for this crap. Quote: and that it was possible to write a number from the keyboard and output to the console Well, you don't actually get a "number" from the keyboard it's an ASCII char (if you use the BIOS, or it's a scan code, then you need a lookup table.), a common example is: Code: ;; Read Num - Read a number from keyboard, (E)DI - Pointer to buffer. read_num: ;; Read a character from keyboard (for Real Mode) xor cx, cx .loop: xor ax, ax ;--Null out ax. int 0x16 ;--Cool. AL = ASCII Char, AH = Scan Code ;; print the number call print_char ;; lazy to write this, but it should print the character to screen ;; with AL = char. ;; don't bother with scan code we need the ASCII char. add al, 48 ; --- Convert to Decimal. may need to add a 'd' iirc. ;; stosb - store a character from AL to DS:(E)DI stosb ;; is cx = 256 (max chars, change if you want to) cmp cx, 256 je .done inc cx jmp .loop .done: .... -sid123 _________________ "Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X XD Last edited by sid123 on 09 Apr 2014, 13:40; edited 3 times in total |
|||
09 Apr 2014, 12:30 |
|
revolution 09 Apr 2014, 13:13
Something to add is that the tasm code above was for an MZ (not a com) file. Hence the .data and .code sections. So we should add a "format mz" line in there and put in the explicit "section ..." lines for data and code.
Also, "mov cx,r" should be "mov cx,[r]". |
|||
09 Apr 2014, 13:13 |
|
sid123 09 Apr 2014, 13:38
revolution wrote: Something to add is that the tasm code above was for an MZ (not a com) file. Hence the .data and .code sections. So we should add a "format mz" line in there and put in the explicit "section ..." lines for data and code. Right, I didn't notice that the value of CX was needed, I thought addresses were needed. Post fixed. Btw COM/MZ shouldn't make a difference for a small program like this, anyways point noted. _________________ "Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X XD |
|||
09 Apr 2014, 13:38 |
|
revolution 09 Apr 2014, 13:49
sid123 wrote: Right, I didn't notice that the value of CX was needed, I thought addresses were needed. TASM also had an "ideal" mode which treated addresses in the same way as fasm does, and the keyword "offset" is then redundant. |
|||
09 Apr 2014, 13:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.